From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3342 invoked by alias); 25 Mar 2015 14:38:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3278 invoked by uid 48); 25 Mar 2015 14:37:57 -0000 From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65509] [5 Regression] [C++11] GCC rejects operator== with two distinct pointers as not constexpr Date: Wed, 25 Mar 2015 15:07:00 -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: 5.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02755.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65509 --- Comment #8 from Marek Polacek --- The following (untested) should work: --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6113,6 +6113,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) not emitted into the object file unnecessarily. */ filename = LOCATION_FILE (input_location); if (!DECL_VIRTUAL_P (decl) + && !DECL_DECLARED_CONSTEXPR_P (decl) && TREE_READONLY (decl) && DECL_INITIAL (decl) != NULL_TREE && DECL_INITIAL (decl) != error_mark_node My reasoning is that we shouldn't defer assembling the variable if it might be needed in the constexpr context.