Received: from eggs.gnu.org ([2001:4830:134:3::10]:58780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXBo3-0003Ke-TC for qemu-devel@nongnu.org; Mon, 07 Apr 2014 11:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXBnz-0008Sx-Mm for qemu-devel@nongnu.org; Mon, 07 Apr 2014 11:49:55 -0400 From: Markus Armbruster References: <1396019577-2013-1-git-send-email-peter.maydell@linaro.org> <1396019577-2013-3-git-send-email-peter.maydell@linaro.org> <5340FDA3.1080902@msgid.tls.msk.ru> <53416107.1080709@msgid.tls.msk.ru> <5342B540.4050005@twiddle.net> Date: Mon, 07 Apr 2014 17:49:46 +0200 In-Reply-To: (Peter Maydell's message of "Mon, 7 Apr 2014 15:47:49 +0100") Message-ID: <87mwfx87hh.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/3] int128.h: Avoid undefined behaviours involving signed arithmetic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Trivial , Patch Tracking , Michael Tokarev , QEMU Developers , Richard Henderson Peter Maydell writes: > On 7 April 2014 15:25, Richard Henderson wrote: >> On 04/06/2014 08:27 AM, Peter Maydell wrote: >>> (if C compilers had a "behave >>> like a sane 2s complement system for signed arithmetic" >>> option I'd be advocating for us using it...) >> >> -fwrapv. > > Well, we should use that then :-) I share your distaste for compilers being perfectly capable to recognize undefined behavior so they can "optimize" working programs into slightly faster broken programs, yet unable to warn me about the very same undefined behavior they so eagerly exploit. -fwrapv is known to be buggy in gcc 4.1. Do we care? It bit the kernel a couple of years ago, and they replaced -fwrapv by -fno-strict-overflow. Commit introducing -fwrapv: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=68df3755e383e6fecf2354a67b08f92f18536594 Commit moving to -fno-strict-overflow: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=a137802ee839ace40079bebde24cfb416f73208a Blog post comparing the two options: http://www.airs.com/blog/archives/120