Re: Undefined compiler behaviour or a compiler bug?

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Thu, 29 Apr 2021 23:11:37 +0200
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.

--HPS
Received on Thu Apr 29 2021 - 19:12:54 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:28 UTC