Undefined compiler behaviour or a compiler bug?

Hans Petter Selasky hps at selasky.org
Thu Apr 29 21:12:54 UTC 2021

On 4/29/21 11:06 PM, Hans Petter Selasky wrote:
> Hi,
> Can someone please explain what C-compiler flag I'm missing, to make 
> this simple C-program terminate?
> I have a function _abs() which at some point is equal to one, but the 
> compiler thinks it is not required to emit the test for the while() at 
> all, looking at the assembly code! A printf() clearly verifies that the 
> _abs() function has returned one.

> clang11 -O2 test.c && ./a.out

Looks like -fwrapv fixes the issue.

Sorry for the noise.


More information about the freebsd-current mailing list