From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 89C393857804; Thu, 15 Oct 2020 11:24:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89C393857804 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/70248] constexpr initialization with unspecified equality expression accepted Date: Thu, 15 Oct 2020 11:24:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2020 11:24:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D70248 --- Comment #8 from Jonathan Wakely --- In gcc/cp/typeck.c:cp_build_binary_op this warning should be an error during constant evaluation for EQ_EXPR and NE_EXPR: if (complain & tf_warning) { tree stripped_orig_op0 =3D tree_strip_any_location_wrapper (orig_= op0); tree stripped_orig_op1 =3D tree_strip_any_location_wrapper (orig_= op1); if ((TREE_CODE (stripped_orig_op0) =3D=3D STRING_CST && !integer_zerop (cp_fully_fold (op1))) || (TREE_CODE (stripped_orig_op1) =3D=3D STRING_CST && !integer_zerop (cp_fully_fold (op0)))) warning_at (location, OPT_Waddress, "comparison with string literal results in " "unspecified behavior"); } And this one for rel ops and spaceships: if (TREE_CODE (orig_op0) =3D=3D STRING_CST || TREE_CODE (orig_op1) =3D=3D STRING_CST) { if (complain & tf_warning) warning_at (location, OPT_Waddress, "comparison with string literal results " "in unspecified behavior"); } That only handles the string literals cases though, we also need to reject pointers to distinct objects at the same places.=