I've just discovered that the following code:
Code: Select all
#include <inttypes.h>
static __attribute__((always_inline)) inline void
bar(uint8_t a) {
/* do nothing */
}
void foo(void)
{
bar(0);
}
Code: Select all
foo: # @foo
push ebp
mov ebp, esp
sub esp, 1 # What? Why are you making the stack unaligned?
mov byte ptr [ebp - 1], 0
add esp, 1
pop ebp
ret
Is this a compiler bug? Notes:
1. It doesn't happen with any other compiler.
2. -O0 -ffreestanding have no effect, I just added to remark that it works online without optimizations and that -ffreestanding have no effect.
3. It happens ONLY when __attribute__((always_inline)) is used
4. It happens ONLY when bar() takes an argument that is < sizeof(void *)
5. It happens ONLY with -m32
As you can imagine, I discovered it while debugging my project, after enabling UBSAN and the real example generates much more code,
but, it doesn't matter. This is the shortest and simplest code that reproduces the problem.
In opinion this is definitively a bug, but what do you think about it?