This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Wrong RTL instruction deleted
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Uros Bizjak <uros at kss-loka dot si>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 27 Dec 2004 14:52:39 +0100
- Subject: Re: Wrong RTL instruction deleted
- References: <41CFC09C.5020302@kss-loka.si>
* Uros Bizjak:
> --cut here--
> #include <stdio.h>
>
> float foo ()
> {
> unsigned int MASK = 0x80000000;
> return (float &) MASK;
> }
>
> int main() {
> printf ("%f\n", foo());
> return 0;
> }
> --cut here--
This is covered by section 5.2.10 in the standard. The return
statement is defined to be equivalent to (see 5.2.10(10)):
return *reinterpret_cast<float *>(&MASK);
5.2.10(9) says that the result of this conversion is unspecified.
(IMHO, the missing warning about a type-punned pointer/reference is a
bug, though.)