public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/62018] FAIL: gcc.dg/torture/ftrapv-1.c * execution test on x86_64-apple-darwin13
Date: Mon, 10 Nov 2014 08:42:00 -0000	[thread overview]
Message-ID: <bug-62018-4-wzSlzFV4w9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62018-4@http.gcc.gnu.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.


  parent reply	other threads:[~2014-11-10  8:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05  9:18 [Bug middle-end/62018] New: " dominiq at lps dot ens.fr
2014-08-05  9:26 ` [Bug middle-end/62018] " rguenth at gcc dot gnu.org
2014-08-05 13:59 ` dominiq at lps dot ens.fr
2014-08-05 14:25 ` dominiq at lps dot ens.fr
2014-08-05 14:52 ` dominiq at lps dot ens.fr
2014-08-20 12:09 ` dominiq at lps dot ens.fr
2014-11-08 22:34 ` fxcoudert at gcc dot gnu.org
2014-11-09 15:56 ` fxcoudert at gcc dot gnu.org
2014-11-09 20:50 ` [Bug target/62018] " fxcoudert at gcc dot gnu.org
2014-11-09 21:06 ` iains at gcc dot gnu.org
2014-11-09 21:19 ` fxcoudert at gcc dot gnu.org
2014-11-10  8:42 ` rguenther at suse dot de [this message]
2014-11-10  8:45 ` rguenther at suse dot de
2014-11-10  8:53 ` fxcoudert at gcc dot gnu.org
2014-11-10  8:58 ` fxcoudert at gcc dot gnu.org
2014-11-10  9:05 ` iains at gcc dot gnu.org
2014-11-10  9:15 ` fxcoudert at gcc dot gnu.org
2014-11-10 15:24 ` fxcoudert at gcc dot gnu.org
2014-11-10 15:38 ` howarth at bromo dot med.uc.edu
2014-11-10 15:41 ` fxcoudert at gcc dot gnu.org
2014-11-10 15:50 ` howarth at bromo dot med.uc.edu
2014-11-10 15:59 ` iains at gcc dot gnu.org
2014-11-10 16:16 ` howarth at bromo dot med.uc.edu
2014-11-23 15:35 ` fxcoudert at gcc dot gnu.org
2014-11-23 15:54 ` fxcoudert at gcc dot gnu.org
2014-11-23 16:08 ` iains at gcc dot gnu.org
2014-11-23 17:46 ` howarth at bromo dot med.uc.edu
2015-10-28 15:06 ` [Bug target/62018] FAIL: gcc.dg/torture/ftrapv-1.c * execution test on x86_64-apple-darwin1[34] rguenth at gcc dot gnu.org
2015-10-28 22:48 ` [Bug target/62018] FAIL: gcc.dg/torture/ftrapv-(1|2).c " dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-62018-4-wzSlzFV4w9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).