This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/62018] FAIL: gcc.dg/torture/ftrapv-1.c * execution test on x86_64-apple-darwin13
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 10 Nov 2014 08:42:35 +0000
- Subject: [Bug target/62018] FAIL: gcc.dg/torture/ftrapv-1.c * execution test on x86_64-apple-darwin13
- Auto-submitted: auto-generated
- References: <bug-62018-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62018
--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> ---
On Sun, 9 Nov 2014, fxcoudert at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62018
>
> --- Comment #8 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
> (In reply to Francois-Xavier Coudert from comment #7)
> > Richard, I am willing to debug this, but don't know where to go after the above analysis.
>
>
> I think it's a libgcc miscompilation somehow. Directly calling __addvsi3 as
> follows:
>
> int __addvsi3 (int, int);
> int main (void)
> { volatile int x = __addvsi3 (__INT_MAX__, 1); }
>
> does not abort, even though (in my understanding) it should.
It definitely does on x86_64-linux. Are you using libgcc_s from
the system (thus darwin)? ISTR old libgcc did the arithmetic
in a bogus way (using undefined behavior). Quoting from GCC 4.3
sources:
Wtype
__addvSI3 (Wtype a, Wtype b)
{
const Wtype w = a + b;
^^^
if (b >= 0 ? w < a : w > a)
abort ();
the addition is done in signed thus invoking undefined behavior.
A fixed variant (trunk) looks like
Wtype
__addvSI3 (Wtype a, Wtype b)
{
const Wtype w = (UWtype) a + (UWtype) b;
if (b >= 0 ? w < a : w > a)
abort ();
doing the addition in unsigned arithmetic.
So I bet apple GCC 4.2 is affected as well - not sure if LLVM
provides libgcc_s on newer systems.