public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113830] GCC accepts invalid code when instantiating the local class inside a function Date: Thu, 08 Feb 2024 13:42:24 +0000 [thread overview] Message-ID: <bug-113830-4-lRYixzezH1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113830-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113830 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Probably we just don't instantiate g because nothing needs it. With template<typename T> void f() { struct S { void g(int n = T::unknown){}; }; S s; s.g(); } template void f<int>(); we error: pr113830.C: In instantiation of ‘void f() [with T = int]’: pr113830.C:6:22: required from here 6 | template void f<int>(); | ^ pr113830.C:2:32: error: ‘unknown’ is not a member of ‘int’ 2 | struct S { void g(int n = T::unknown){}; }; | ^~~~~~~ pr113830.C:4:6: note: when instantiating default argument for call to ‘void f()::S::g(int) [with T = int]’ 4 | s.g(); | ~~~^~ but when one uses s.g(0); instead of s.g(); we accept it as well.
next prev parent reply other threads:[~2024-02-08 13:42 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-08 12:41 [Bug c++/113830] New: " wangbopku15 at gmail dot com 2024-02-08 13:01 ` [Bug c++/113830] " redi at gcc dot gnu.org 2024-02-08 13:08 ` mpolacek at gcc dot gnu.org 2024-02-08 13:24 ` wangbopku15 at gmail dot com 2024-02-08 13:38 ` wangbopku15 at gmail dot com 2024-02-08 13:42 ` jakub at gcc dot gnu.org [this message] 2024-02-08 13:53 ` mpolacek at gcc dot gnu.org 2024-02-08 14:14 ` wangbopku15 at gmail dot com 2024-02-08 15:01 ` redi at gcc dot gnu.org 2024-02-08 15:10 ` wangbopku15 at gmail dot com 2024-02-08 15:36 ` jakub at gcc dot gnu.org 2024-02-08 19:08 ` wangbopku15 at gmail dot com 2024-02-08 19:47 ` harald at gigawatt dot nl 2024-02-09 2:44 ` wangbopku15 at gmail dot com 2024-02-09 9:26 ` harald at gigawatt dot nl
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113830-4-lRYixzezH1@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).