This is the mail archive of the gcc-patches@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: [SPARC] Fix PR target/60941


Eric Botcazou writes:
 > > > Not clear to me, (2U << i) should be zero if the shift count is masked.
 > > 
 > > 2U << 31 is undefined behavior on those targets.
 > 
 > Precisely not, or else we are not talking about the same notion of masking.

I believe Jakub is referring to the following in the C standard:

"Bitwise shift operators
...
Semantics
...  If the value of the right operand ... is greater than or equal to the
width of the promoted left operand, the behavior is undefined."

So on 16-bit int systems you can't portably shift 2U by more than 15.

(I'm not worried about the HW blowing up, but GCC itself has a long history
of exploiting no-undefinedness assumptions.)

/Mikael


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