This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wrong RTL instruction deleted


* 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.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]