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: GCC aliasing rules: more aggressive than C99?


On 01/03/2010 11:25 PM, Richard Guenther wrote:
>    char charray[sizeof(long)] = {...};
>    long l = *(long*)charray;  // ok

not correct;) (the lvalue has to be of character type, yours is of type 'long' - the type of the actual object does not matter)

What would be correct instead is


memcpy ((char *) &l, charray, sizeof(long));

Paolo


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