This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/69984] [4.9/5/6] Signed comparison instruction emitted for unsigned variable comparison


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

--- Comment #6 from Edmar Wienskoski <edmar at freescale dot com> ---
Hummm, You are almost convincing me, one last question,
be patient with me.

As Andrew posted:
C = A * B
should be equivalent to:
C = (unsigned long)( ((int)A) * ((int)B) )

The variables are promoted *before* the multiplication.
How come (int)65535 multiplied by itself is undefined behavior ?

Or (unsigned short) 0x7FFF multiplied by itself, would not be undefined
behavior as well ?

In fact, re-writing the code as above, will generate unsigned comparison.

So, why "C = A * B" is not doing the same ?

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