https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
--- Comment #6 from Andrew Pinski ---
(In reply to Ada Liu from comment #5)
> But (65536*d[1]+d[0]) is convered to (unsigned long), should not be treated
> as unsigned?
NO. Both C and C++ language is clear here about the expression "65536*d[1]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
--- Comment #5 from Ada Liu ---
(In reply to Andrew Pinski from comment #3)
> 65536*d[1] will overflow if d[1] is 65535 (0x).
>
> If you did this instead it would be defined:
> 65536u*d[1]
>
> as that is an unsigned * unsigned short so the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
--- Comment #4 from Andrew Pinski ---
Note you can also use -fwrapv to get the behavior you want.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
Andrew Pinski changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
--- Comment #2 from Ada Liu ---
Comment on attachment 41567
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41567
reduced testcase
>
>unsigned short d[2];
>__attribute__ ((noinline))int DiffInt ()
>{
> if ((unsigned long)(65536*d[1]+d[0]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81110
--- Comment #1 from Ada Liu ---
Comment on attachment 41567
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41567
reduced testcase
>
>unsigned short d[2];
>__attribute__ ((noinline))int DiffInt ()
>{
> if ((unsigned long)(65536*d[1]+d[0]