News for hackers. Stuff that matters.
Re:So you think you know C? by ryao on Saturday January 20, 2024 @06:37PM (#39073706)
The first 4 are implementation defined rather than undefined.

That said, warnings do not necessarily mean that the code is invoking undefined behavior. For example, with if (a = b) GCC will generate a warning, unless you do if ((a = b)). The reason for the warning is that often people mean to do equality and instead write assignment by mistake, so the compilers warn unless a second set of braces is used to signal that you really meant to do that.

Re:So you think you know C? by o11c on Saturday January 20, 2024 @06:40PM (#39073728)
In the cases involving overflow, it's implementation-defined whether there's undefined behavior.
Re:So you think you know C? by turminal on Saturday January 20, 2024 @06:43PM (#39073755)
> The first 4 are implementation defined rather than undefined.

Third and fourth are only defined in some implementations.

Re:So you think you know C? by ryao on Saturday January 20, 2024 @07:56PM (#39074299)
That is fair for 4, although would explain why it is the case for 3?
Re:So you think you know C? by turminal on Sunday January 21, 2024 @10:34AM (#39079342)
If char is signed and ' ' * 13 is bigger than CHAR_MAX, you get UB by signed overflow.