Bug 235008 - Bad compilation error message when on casting a constant pointer
Bad compilation error message when on casting a constant pointer
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc (Show other bugs)
4.0
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-04-03 05:07 EDT by cb
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version: RHBA-2007-0803
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-11-15 11:08:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
gcc34-rh235008.patch (1.30 KB, patch)
2007-04-12 18:26 EDT, Jakub Jelinek
no flags Details | Diff

  None (edit)
Description cb 2007-04-03 05:07:54 EDT
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 03:33:18 EDT
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 05:44:11 EDT
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 18:26:21 EDT
Created attachment 152512 [details]
gcc34-rh235008.patch

That's a translation bug.
Comment 4 RHEL Product and Program Management 2007-07-18 14:24:57 EDT
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 11:08:48 EST
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.