From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C1B07388702E; Mon, 13 Apr 2020 21:04:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1B07388702E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586811888; bh=QD8fNoMr9+Qazo0hVwg5xgJ0K+cuxBUT7yjiRelxUJY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XivUjoDoEqjZCzZG542PSF0bQiKHV8J2US09BA+BLny1a/IDdYHteT6jbCGzEzW5F LfhtTeMmkJpp8xNnSJs52mWXKqwjNb3gW0S59jibpqxP1EWjyFYCWZDAA0dotY8SSK vJPeMxe6V+ts5pmNLUAHlJWmzbRCxZsjermybQ8A= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94470] [8/9/10 Regression] Constexpr variable initialization with self-modifying constructor incorrectly rejected since r7-6728 Date: Mon, 13 Apr 2020 21:04:48 +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: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 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, 13 Apr 2020 21:04:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94470 --- Comment #1 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:077dd9b3f17710da8af6adce816754ddceb57b5a commit r10-7704-g077dd9b3f17710da8af6adce816754ddceb57b5a Author: Patrick Palka Date: Mon Apr 13 16:53:02 2020 -0400 c++: More self-modifying constexpr init [PR94470] In this PR we're incorrectly rejecting a self-modifying constexpr initializer as a consequence of the fix for PR78572. It looks like however that the fix for PR78572 is obsoleted by the fix = for PR89336: the testcase from the former PR successfully compiles even with its fix reverted. But then further testing showed that the analogous testcase of PR78572 where the array has an aggregate element type is still problematic (i.e. we ICE) = even with the fix for PR78572 applied. The reason is that in cxx_eval_bare_aggre= gate we attach a constructor_elt of aggregate type always to the end of the new CONSTRUCTOR, but that's not necessarily correct if the CONSTRUCTOR is self-modifying. We should instead be using get_or_insert_ctor_field to insert the constructor_elt in the right place. So this patch reverts the PR78572 fix and makes the appropriate changes= to cxx_eval_bare_aggregate. This fixes PR94470, and we now are also able = to fully reduce the initializers of 'arr' and 'arr2' in the new test array57.C to constant initializers. gcc/cp/ChangeLog: PR c++/94470 * constexpr.c (get_or_insert_ctor_field): Set default value of parameter 'pos_hint' to -1. (cxx_eval_bare_aggregate): Use get_or_insert_ctor_field instead= of assuming the the next index belongs at the end of the new CONSTRUCTOR. (cxx_eval_store_expression): Revert PR c++/78572 fix. gcc/testsuite/ChangeLog: PR c++/94470 * g++.dg/cpp1y/constexpr-nsdmi8.C: New test. * g++.dg/cpp1y/constexpr-nsdmi9.C: New test. * g++.dg/init/array57.C: New test.=