Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 235008 - Bad compilation error message when on casting a constant pointer
Summary: Bad compilation error message when on casting a constant pointer
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc
Version: 4.0
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-03 09:07 UTC by cb
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Fixed In Version: RHBA-2007-0803
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-11-15 16:08:48 UTC
Target Upstream Version:


Attachments (Terms of Use)
gcc34-rh235008.patch (deleted)
2007-04-12 22:26 UTC, Jakub Jelinek
no flags Details | Diff


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2007:0803 normal SHIPPED_LIVE gcc bug fix update 2007-11-14 17:44:01 UTC

Description cb 2007-04-03 09:07:54 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

Description of problem:
When I compile this code, I obtain an internal error of compiler.
I whould like a simple error message.

#include <assert.h>
class AA
{
  int i;
};

class AB : public AA
{
public:
  int j;
};


void fct(const AA* a)
{
  const AB* p_ab = static_cast<AB *>(a);
  assert(p_ab->j == 2);
}

int main()
{
  AB ab;
  ab.j = 2;
  fct(&ab);

  return 0;
}


Version-Release number of selected component (if applicable):
gcc 3.4.6

How reproducible:
Always


Steps to Reproduce:
1.compile this code
2.
3.

Actual Results:
Please submit a full bug report
;-)

Expected Results:
An error message, for example: 
'invalid convertion of " AB* " to " const AB* "'

Additional info:
For information, the correct line is: 
  const AB* p_ab = static_cast<const AB *>(a);

Comment 1 Alexandre Oliva 2007-04-10 07:33:18 UTC
Can you please confirm what version of GCC you're using?  I haven't been able to
duplicate this with the U4 gcc:

$ g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
$ g++ bz235008.cc 
bz235008.cc: In function `void fct(const AA*)':
bz235008.cc:16: error: static_cast from type `const AA*' to type `AB*' casts
away constness


Comment 2 cb 2007-04-10 09:44:11 UTC
I use a french gcc version. Moreover, I use a machine virutal (VMware) for
launching Linux AS4. Perhaps thus the problem comes from their image.

$ gcc -v
Lecture des spcification  partir de /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configur avec: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Modle de thread: posix
version gcc 3.4.6 20060404 (Red Hat 3.4.6-3)

$ make bug_gcc
g++     bug_gcc.cpp   -o bug_gcc
bug_gcc.cpp: In function `void fct(const AA*)':

erreur interne au compilateur : routine de rapport d'erreur prempte.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccuRsD9O.out file, please attach this to
your bugreport.
make: *** [bug_gcc] Erreur 1


(In reply to comment #1)
> Can you please confirm what version of GCC you're using?  I haven't been able to
> duplicate this with the U4 gcc:
> 
> $ g++ -v
> Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --with-system-zlib --enable-__cxa_atexit
> --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
> $ g++ bz235008.cc 
> bz235008.cc: In function `void fct(const AA*)':
> bz235008.cc:16: error: static_cast from type `const AA*' to type `AB*' casts
> away constness
> 

Comment 3 Jakub Jelinek 2007-04-12 22:26:21 UTC
Created attachment 152512 [details]
gcc34-rh235008.patch

That's a translation bug.

Comment 4 RHEL Product and Program Management 2007-07-18 18:24:57 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 10 errata-xmlrpc 2007-11-15 16:08:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2007-0803.html



Note You need to log in before you can comment on or make changes to this bug.