From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2CEDE3858C35; Fri, 9 Feb 2024 02:44:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CEDE3858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707446671; bh=wsn+O/YUrvCtcAMxYvYWGMkvGA6S3DWSi/ncf1pkJS4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j7kG7YKnycygmGKFzxk7OthsVi3KTv0MiqByys4NISRbRe+hSrVAUHKcv8MKQl9Yd phY/vvq5yCWe6F0sVXhjtG1+ISBFlVfLZhuaNnzk30HmOnzdhA4zEn+M7CKXICAD9s CzFbT430oA4D2o+OpLw5DUZcWLKUCMCKQIqBrH2E= From: "wangbopku15 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113830] GCC accepts invalid code when instantiating the local class inside a function Date: Fri, 09 Feb 2024 02:44:30 +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: 13.2.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: wangbopku15 at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113830 --- Comment #13 from Bo Wang --- (In reply to Harald van Dijk from comment #12) > (In reply to Bo Wang from comment #11) > > I have read the working draft standard of C++20 > > (https://github.com/cplusplus/draft/tree/c%2B%2B20). > >=20 > > Following the subsection "13.9.2 Explicit instantiation" in the section > > "13.9 Template instantiation and specialization", the statement `templa= te > > void f();` is an explicit instantiation, which requires instantiat= ing > > everything in the function. >=20 > Where are you getting "everything in the function" from? It seems to say > rather the opposite in [temp.explicit]p14: >=20 > > An explicit instantiation does not constitute a use of a default argume= nt, so default argument instantiation is not done. >=20 > Now, the example shows that this was intended to apply to default argumen= ts > of the function itself, but the actual wording does not limit it to that,= so > I actually think this is a bug in clang, by the current wording this must= be > accepted? Please refer to the example in Comment 9 which has no default arguments. For the standard, I found this one in "13.9 Template instantiation and specialization" p6 of C++20, which requires access checking. > The usual access checking rules do not apply to names in a declaration of= an=20 > explicit instantiation or explicit specialization, with the exception of = names=20 > appearing in a function body, default argument, base-clause, member- > specification, enumerator-list, or static data member or variable templat= e=20 > initializer. [Note: In particular, the template arguments and names used = in the=20 > function declarator zincluding parameter types, return types and exceptio= n=20 > specifications) may be private types or objects that would normally not be > accessible. =E2=80=94end note] Also, I don't think Clang rejecting these codes is buggy.=