From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 880EB3858D38; Wed, 25 Jan 2023 15:52:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 880EB3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674661956; bh=f6GBGHC+CireDN4G4dlGjHz4VK3Y/X+TvfT1zPO2RHM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NOrRrTI/3tANykzKKCNLo36eVTAd9nhdS7QRaGFjwkmwvWEo9/DprUfM+5Qx4qewB t7rxWNpd03X0rGEKEy+pN7Ciaf8pjZss7hycLWItJDJQrt3Odby8xmjd+1oOTdw6uC E5QGfsilFNWFIMH1X6Y8Avt2Wnb5scLPCryxx2og= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108540] [13 Regression] Frange miscompilation of ruby since r13-3261 Date: Wed, 25 Jan 2023 15:52:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc target_milestone everconfirmed priority Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108540 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2023-01-25 CC| |aldyh at gcc dot gnu.org, | |amacleod at redhat dot com Target Milestone|--- |13.0 Ever confirmed|0 |1 Priority|P3 |P1 --- Comment #1 from Jakub Jelinek --- stdarg.h isn't needed, so: __attribute__((noipa)) void bar (const char *cp, unsigned long size, char sign, int dsgn) { if (__builtin_strcmp (cp, "ZERO") !=3D 0 || size !=3D 4 || sign !=3D '-' = || dsgn !=3D 1) __builtin_abort (); } __attribute__((noipa)) void foo (int x, int ch, double d) { const char *cp =3D ""; unsigned long size =3D 0; char sign =3D '\0'; switch (x) { case 42: if (__builtin_isinf (d)) { if (d < 0) sign =3D '-'; cp =3D "Inf"; size =3D 3; break; } if (__builtin_isnan (d)) { cp =3D "NaN"; size =3D 3; break; } if (d < 0) { d =3D -d; sign =3D '-'; } else if (d =3D=3D 0.0 && __builtin_signbit (d)) sign =3D '-'; else sign =3D '\0'; if (ch =3D=3D 'a' || ch =3D=3D 'A') { union U { long long l; double d; } u; int dsgn; u.d =3D d; if (u.l < 0) { dsgn =3D 1; u.l &=3D 0x7fffffffffffffffLL; } else dsgn =3D 0; if (__builtin_isinf (d)) { cp =3D "INF"; size =3D 3; } else if (__builtin_isnan (d)) { cp =3D "NAN"; size =3D 3; } else if (d =3D=3D 0) { cp =3D "ZERO"; size =3D 4; } else { cp =3D "WRONG"; size =3D 5; } bar (cp, size, sign, dsgn); } } } int main () { foo (42, 'a', -0.0); return 0; } The testcase is hand-written from what I see in https://github.com/ruby/ruby/blob/a528908271c678360d2d8ca232c178e7cdd340b4/= vsnprintf.c#L529 https://github.com/ruby/ruby/blob/a528908271c678360d2d8ca232c178e7cdd340b4/= vsnprintf.c#L1229 https://github.com/ruby/ruby/blob/a528908271c678360d2d8ca232c178e7cdd340b4/= missing/dtoa.c#L3387 where hdtoa is inlined into cvt which is inlined into vfprintf. This reduc= ed testcase reproduces on x86_64-linux too.=