From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 704DA3857375; Fri, 22 Apr 2022 10:42:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 704DA3857375 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/88165] error: default member initializer for 'A::B::m' required before the end of its enclosing class Date: Fri, 22 Apr 2022 10:42:52 +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.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: Fri, 22 Apr 2022 10:42:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88165 --- Comment #14 from Jonathan Wakely --- (In reply to andysem from comment #13) > (In reply to Jonathan Wakely from comment #10) > > > C(D =3D {}); > >=20 > > This requires checking whether C::D is default constructible, but we are > > still in the body of C, so C is not complete, which means C::D is not > > complete, which means we don't know if C::D is default constructible. >=20 > Does it? I thought the default arguments were only evaluated at the point > where they are actually used, i.e. in this case - when `C` constructor is > invoked with no arguments. It's surprising, I agree. Whether the default argument is valid determines whether this constructor is considered a default constructor, which determi= nes whether the compiler needs to implicitly declare a separate default constru= ctor I think that's why the default argument is needed earlier than you expect. > If this is how the standard specifies compiler behavior, I wonder if this > should be considered as a defect (DR).=20 I closed this as a dup of PR 96645 which has a DR number right there in the title. Like I said, see there for more details. > There is nothing in > `std::numeric_limits::max()` that depends on the definition of `C= `, > so there is no reason to prevent it from compiling. Are you sure? What if C::std is declared? Then the initializer means someth= ing very different. Again, see PR 96645 for further discussion of when the initializer can be compiled (and a possible patch to do it differently).=