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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to John Hunter from comment #4)
> The annotation of Constants with `ul' is a fudge. In the specimen program,
> a constant (1) is assigned to an unsigned long variable (wk) which forces it

If you are talking about wk = 1 << j;, then it really doesn't matter what type
the wk variable has, this is assigning the value of 1 << j into the wk
variable,
so 1 << j is first evaluated and then converted into unsigned long and stored.

(In reply to Jakub Jelinek from comment #6)
> And, again on 32-bit int targets, (1 << 24) << 7 is well defined, but 0.

Sorry, thought about (1 << 24) << 8; and it is well defined in C++, still
undefined behavior in C99.  For (1 << 24) << 7, it is again INT_MIN in C++, UB
in C99.  You really want (1U << 24) << 8 (if you want to get 0), or (1ULL <<
24) << 7 (if you want to get 0x100000000ULL.

Reply via email to