From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 52C3F388C015; Mon, 8 Mar 2021 13:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52C3F388C015 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99456] [11 regression] ABI breakage with some static initialization Date: Mon, 08 Mar 2021 13:39:50 +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: 11.0 X-Bugzilla-Keywords: ABI, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 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, 08 Mar 2021 13:39:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99456 --- Comment #8 from Jakub Jelinek --- I'm not misreading the testcase, I'm just reacting on the fact that my patch changed the behavior of it and looking into related issues when analyzing w= hy. It is up to the compiler to decide if it can or can't optimize it. The strange thing is that before my patch, it was actually triggerring the now removed cxx_eval_outermost_constant_expression code: /* Technically we should check this for all subexpressions, but that runs into problems with our internal representation of pointer subtraction and the 5.19 rules are still in flux. */ if (CONVERT_EXPR_CODE_P (TREE_CODE (r)) && ARITHMETIC_TYPE_P (TREE_TYPE (r)) && TREE_CODE (TREE_OPERAND (r, 0)) =3D=3D ADDR_EXPR) { if (!allow_non_constant) error ("conversion from pointer type %qT " "to arithmetic type %qT in a constant expression", TREE_TYPE (TREE_OPERAND (r, 0)), TREE_TYPE (r)); non_constant_p =3D true; } but with allow_non_constant false. Which means the call didn't return (uintptr_t) &desc (the folded expression), but (uintptr_t) (unsigned int *) descRef (an unfolded one). And strangely that one then led to no dynamic initialization, while the folded one doesn't.=