https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110530

--- Comment #2 from Haiqing Zhao <haiqingzhao at microsoft dot com> ---
(In reply to Andrew Pinski from comment #1)
> This code is undefined for 2 reasons.
> 
> First is unsigned int and unsigned long are 2 different sizes on LP64
> targets (x86_64-linux-gnu is one of those, while windows is not).
> Second is if they are the same size, then there is an aliasing violation in
> that you cannot do a store as an `unsigned long` and then do a load from
> that same location as an `unsigned int` as C says those 2 types don't alias.
> 
> 
> -fsanitize=address will catch the first reason.

Dear Andrew,

Thanks a lot for your prompt explanation. I tested on a 32-bit platform and the
issue shall be due to the neglect of strict aliasing. With the experiment which
addes -fno-strict-alising when compiling, the code can also execute normally.
Again thanks for your information.

Sincere Regards,
Haiqing

Reply via email to