------- Additional Comments From dirk at cle-mens dot de  2005-02-26 10:35 
-------
(In reply to comment #1)
> Invalid you are violating C90/C99 aliasing rules.

Ok. But where is the compiler warning?

The dokumentation of gcc says: (man gcc)
-Wstrict-aliasing
 This option is only active when -fstrict-aliasing is active.  It
 warns about code which might break the strict aliasing rules that
 the compiler is using for optimization. The warning does not
 catch all cases, but does attempt to catch the more common pit‐
 falls. It is included in -Wall.

But the compiler don't give any warning!
And this is a compiler error in category warnings.

P.S.: I have minimized the Programm that shows this error:

#include <stdlib.h>
#include <stdio.h>

typedef unsigned int uint32;
typedef unsigned long long uint64;

struct data
{
    uint32 lo;
    uint32 hi;
};

inline uint64 GetData ( const struct data * d )
{
    const uint64 *p = (uint64*)d; // <<<<<<<<<<<<<<<<<<<<
    return *p;
}

int main( int argc, char ** argv )
{
    struct data D = {1,2};
    uint64 u64 = GetData(&D);
    printf("%016llx\n",u64);
    return 0;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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

Reply via email to