------- Comment #1 from rguenth at gcc dot gnu dot org  2009-04-25 13:38 -------
Casting through a union (2)

describes an invalid way of doing type-punning.

The only conforming and portable way is

unsigned bar(char *x)
{
    unsigned un;
    memcpy (&un, x, sizeof (un));
    return un;
}

I have no opinion on the different levels of warnings (I think this case
should be unconditionally).


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-25 13:38:51
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39895

Reply via email to