From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 582323858423; Fri, 4 Nov 2022 13:27:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 582323858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667568447; bh=G0cCUpOqupH/JcqVX50ua1NQmeKjDkSXl9BJXdFeVvE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gj02EP0bM62wzCTTuDza3tCUUPeB3fiDnTQapb1+UO5g/5Of2AKvT43UH9Ccj8LZd 97Bkywo9sUI/DwUGpoeS85Qi+fZ+CQJIH3E0N+OdByVnSpsuHdVbvwXsOTOW4IFdD/ swM5qDHQXIxfeGhPfc/NxxVfqdpI+z7m/GsrSgc8= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/86369] constexpr const char* comparison fails Date: Fri, 04 Nov 2022 13:27:19 +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: 8.1.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D86369 --- Comment #10 from Jakub Jelinek --- (In reply to Aaron Ballman from comment #9) > Doesn't [expr.eq] make it unspecified though? Will defer that answer to Jason. But please have a look at the comment 6 testcase. I strongly hope that constexpr const char *p =3D "abc"; constexpr const char *q =3D p; static_assert (p =3D=3D q, ""); doesn't actually mean the string literal is evaluated multiple times, becau= se if it would be, then one pretty much can't use string literals for anything reliably. I bet the wording in there is for the constexpr const char *r =3D "abc"; constexpr const char *s =3D "abc"; case, where the standard doesn't force implementations to unify same string literals within the same TU but allows it (and also allows say tail merging= of them). From what I can see in the LLVM constant expression evaluation behavior, it doesn't track what comes from which evaluation of a string lit= eral (GCC doesn't track that either) and just assumes that it could be different evaluation, while GCC assumes it is not.=