From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D7165385828C; Fri, 24 Nov 2023 14:56:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7165385828C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700837817; bh=YdTg+D+31UEP8ZCUETdSmGdvhNIAAPZda07rT3xI33o=; h=From:To:Subject:Date:From; b=odQ6xASxxGXgEFEkZ+9vnqcPabM9CRvOU/cF1QVbe4OMIW1NDeQo9As4KBsNzcsFG 2AhWVDR2BFcFPQTN38SKnGK1MEfl+OjHCtHrJKT5wO56ksTa/jq/0D/MDXjsNkKI2L oyzCPZIz1/coWeGC0S+BHB9+PLPj2vLQJd8ExHek= From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/112701] New: wrong type inference for ternary operator in preprocessing context Date: Fri, 24 Nov 2023 14:56:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D112701 Bug ID: 112701 Summary: wrong type inference for ternary operator in preprocessing context Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: amonakov at gcc dot gnu.org Target Milestone: --- In the following snippet, the result of the ternary operator is (-1, cast t= o an unsigned type), so the comparison yields false, and both conditional inclus= ions must come out empty: #if (0 ? 0u : -1) < 0 int foo =3D (0 ? 0u : -1) < 0; #endif #if (0 ? 0/0u : -1) < 0 int bar =3D (0 ? 0/0u : -1) < 0; #endif However, GCC emits: bar: .zero 4 So clearly the evaluation of the second expression is inconsistent between preprocessing context (where it incorrectly yields 1) vs. initializer conte= xt (where it is zero as it should be, as seen from the resulting asm).=