This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc
- From: nathan at gcc dot gnu dot org
- To: aloeff at de dot ibm dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 11 Sep 2002 09:19:00 -0000
- Subject: Re: optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc
- Reply-to: nathan at gcc dot gnu dot org, aloeff at de dot ibm dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: code compiled with optimization flag causes segmentation violation on powerpc
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Wed Sep 11 02:18:59 2002
State-Changed-Why:
This is not a bug, but I expected a warning (which we used
to give). '(char *)foo' is an rvalue. the call through
to 'char *&ref' binds an rvalue to a non-const reference.
That is ill-formed. It binds to a temporary copy, thus
the pointer seen by the function is not the object
you cast.
The correct solution is the cast to an lvalue,
'(char *&)foo'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7884