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

--- Comment #2 from Eugeniu Rosca <roscaeugeniu at gmail dot com> ---
Hi Andrew,

> As an extension to the C language, GCC does not use the latitude given in C99 
> and C11 only to treat certain aspects of signed ‘<<’ as undefined. However, 
> -fsanitize=shift (and -fsanitize=undefined) will diagnose such cases.

I think my report is purely and precisely related to left-shifting of 1 into
the sign bit (i.e. a subset of all possible '<<'-related UB) and  I provide
evidence that UBSAN behaves differently between the C89/C90 and C11/C18
implementations.

I have backed up my questions with real-life motivation (Linux kernel is
compiled with -std=gnu89 while U-Boot/coreboot are compiled with -std=gnu11),
which means my questions do not come from some theoretical curiosity.

Your quote is helpful, but it still doesn't explain why (1 << 31) is defined
behavior in C89/C90, but not in C99/C11/C18, which triggers one
order-of-magnitude more UBSAN warnings in C11-compiled code compared to
C89-compiled one. Can you shed some light on this?

Reply via email to