From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63908398641F; Tue, 30 Aug 2022 15:19:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63908398641F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661872793; bh=MKe4dQjKbLV5+nmqWKtiTfewBIDGyjyVfbt6lFTCZxs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RlEphFkoXJjXb0dAo5SHUpS8jFS0BmNPIzzlDOdp3LcQY69FEeCxR2egKZGXswAYr ulR2c3Yc7qD5RQJQiVfoWxhXpt3zVktlYVd1bDE9OzTjvo5MPVOsK8l9AprbysIAtm zjmxmbYan4hUsPVRe2zoycD+zJrrdZgk8X3chqno= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug testsuite/31290] gcc.c-torture/execute/920612-1.c and gcc.c-torture/execute/920711-1.c depend on signed overflow being defined Date: Tue, 30 Aug 2022 15:19:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: testsuite X-Bugzilla-Version: 4.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D31290 --- Comment #5 from Andrew Pinski --- (In reply to Philipp from comment #4) > I disagree about this bug for gcc.c-torture/execute/920711-1.c. I think > there was no bug here, and the "fix" actually introduced a problem, and > should be reverted: No there is a bug. int f(long a){return (--a > 0);} int main(){if(f(0x80000000L)=3D=3D0)abort();exit(0);} 0x80000000L is still 0x80000000 bitwise. so we get 0x80000000L - 1 which is undefined if long is 32bits. If long is 64bits then 0x80000000L is still th= at (and no implementation defined casting) and not undefined there. > By section 4.5 of the GCC manual https://gcc.gnu.org/onlinedocs/gcc/Integ= ers-implementation.html#Integers-implementation the result of the conversio= n is -1. No it is INT_MIN (for 32bit long): For conversion to a type of width N, the value is reduced modulo 2^N to be within range of the type; no signal is raised. That means 0x80000000ULL will be 0x80000000L (if long is 32bits and long lo= ng is 64bit).=