RTEMS | kern_ntptime.c: Negative Shift Value Warning (#5339)

Joel Sherrill (@joel) gitlab at rtems.org
Fri Sep 19 17:48:10 UTC 2025




Joel Sherrill commented on a discussion: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5339#note_132733


This warning is generated on all targets and BSPs. Per Section 6.5.7 Bitwise shift operators in the C11 standard, many of the possible cases are undefined behavior:

> The result of E1 \<\< E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 × 2E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1 × 2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined. 
>
> The result of E1 \>\> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 /2E2. I f E1 has a signed type and a negative value, the resulting value is implementation-defined.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5339#note_132733
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250919/20d74a18/attachment.htm>


More information about the bugs mailing list