Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Apr 2021 23:11:37 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        FreeBSD Current <freebsd-current@freebsd.org>, Konstantin Belousov <kib@FreeBSD.org>
Subject:   Re: Undefined compiler behaviour or a compiler bug?
Message-ID:  <16b60c22-be04-cbbf-8fc4-a90c4031c529@selasky.org>
In-Reply-To: <59f81323-74c5-e6a8-a62d-6abdf78902e8@selasky.org>
References:  <59f81323-74c5-e6a8-a62d-6abdf78902e8@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16b60c22-be04-cbbf-8fc4-a90c4031c529>