From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A4B53858410; Mon, 3 Jan 2022 12:48:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A4B53858410 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94716] comparison of address of template variables should be constexpr Date: Mon, 03 Jan 2022 12:48:46 +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: 10.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: Mon, 03 Jan 2022 12:48:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94716 --- Comment #5 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:91031bffa42fdea3c985727d042cd1882a64be9c commit r12-6188-g91031bffa42fdea3c985727d042cd1882a64be9c Author: Jakub Jelinek Date: Mon Jan 3 13:47:53 2022 +0100 symtab: Fold &a =3D=3D &b to 0 if folding_initializer [PR94716] On Thu, Dec 09, 2021 at 06:09:12PM -0500, Jason Merrill wrote: > For the more general comparison of decls like your a !=3D b example a= bove I > think clang is in the right; in manifestly constant-evaluated context > (folding_initializer) we should return that they are unequal and prev= ent a > later alias declaration, like we do for comparison to 0 in > maybe_nonzero_address. It's possible that this gives a wrong answer based > on something in another translation unit, but that's unlikely, and ta= king > that chance seems better than rejecting code that needs a constant answer. I agree. This is an incremental patch to do that. 2022-01-03 Jakub Jelinek PR c++/94716 gcc/ * symtab.c: Include fold-const.h. (symtab_node::equal_address_to): If folding_initializer is true, handle it like memory_accessed. Simplify. gcc/testsuite/ * gcc.dg/init-compare-1.c: New test. * g++.dg/cpp0x/constexpr-compare1.C: New test. * g++.dg/cpp1y/constexpr-94716.C: New test. * g++.dg/cpp1z/constexpr-compare1.C: New test.=