Category "undefined-behavior"

Why does GCC include an "empty" XOR

I have following piece of code: typedef struct { int x; int y; int z; int w; } s32x4; s32x4 f() { s32x4 v; v.x

How can I safely add and clamp a signed integer in C?

I have a value, of type signed int, which is always clamped between, for example, ±1073741824 (2^30). I should be able to safely add or subtract any arbi

Does the C++ standard allow for an uninitialized bool to crash a program?

I know that an "undefined behaviour" in C++ can pretty much allow the compiler to do anything it wants. However, I had a crash that surprised me, as I assumed t

Does gcc initialize long strings to `""` but not short ones?

Note: I know that reading an uninitialized string is undefined behaviour. This question is specifically about the GCC implementation. I am using GCC version 6.2

How undefined are __builtin_ctz(0) or __builtin_clz(0)?

Background For a long time, gcc has been providing a number of builtin bit-twiddling functions, in particular the number of trailing and leading 0-bits (also f