public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pacoarjonilla at yahoo dot es" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94619] New: String literals as non-type template parameter fails to compile with partial specialization of calling function Date: Thu, 16 Apr 2020 14:20:24 +0000 [thread overview] Message-ID: <bug-94619-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94619 Bug ID: 94619 Summary: String literals as non-type template parameter fails to compile with partial specialization of calling function Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pacoarjonilla at yahoo dot es Target Milestone: --- I'm not sure if this is correct C++, but the compiler seems to be unable to deduce the template parameter of fu when it is a non-type kind. If the code is not correct, this error blocks fu from being overloaded by more specific templates :( The diagnostic " mismatched types ‘A<length>’ and ‘A<...auto...>’ " is suspicious of a bug in GCC >>>>>>>>>>>>>>>>>>>>>>>>>>> template <unsigned length> struct A { char str [length]; constexpr A(char const (&s) [length]) { for (int i = 0; i < length; ++i) str[i] = s[i]; } }; template <A a> struct B { void bar() const { return a.str; } }; //template <typename T> void fu (T const& t) // Compiles successfully template <A a> void fu (B<a> const& t) // Does not compile //template <unsigned l> void fu (B<A<l>> const& t) // Does not compile either { t.bar(); } void test() { B<":/"> m; fu(m); } >>>>>>>>>>>>>>>>>>>>>>>>>>> gcc10 --std=c++20 code.cc -c meta.cc:17:37: error: class template argument deduction failed: 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc:17:37: error: no matching function for call to ‘A(A<...auto...>)’ meta.cc:4:15: note: candidate: ‘template<unsigned int length> A(const char (&)[length])-> A<length>’ 4 | constexpr A(char const (&s) [length]) { | ^ meta.cc:4:15: note: template argument deduction/substitution failed: meta.cc:17:37: note: mismatched types ‘const char [length]’ and ‘A<...auto...>’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc:1:35: note: candidate: ‘template<unsigned int length> A(A<length>)-> A<length>’ 1 | template <unsigned length> struct A { | ^ meta.cc:1:35: note: template argument deduction/substitution failed: meta.cc:17:37: note: mismatched types ‘A<length>’ and ‘A<...auto...>’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc: In function ‘void fu(const int&)’: meta.cc:20:9: error: request for member ‘bar’ in ‘t’, which is of non-class type ‘const int’ 20 | t.bar(); | ^~~ meta.cc: In function ‘void test()’: meta.cc:25:9: error: no matching function for call to ‘fu(B<A<3>{":/"}>&)’ 25 | fu(m); | ^ meta.cc:17:30: note: candidate: ‘template<A<...auto...> a> void fu(const int&)’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^~ meta.cc:17:30: note: template argument deduction/substitution failed: meta.cc:25:9: note: couldn’t deduce template parameter ‘a’ 25 | fu(m); | ^
next reply other threads:[~2020-04-16 14:20 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-16 14:20 pacoarjonilla at yahoo dot es [this message] 2020-04-16 16:07 ` [Bug c++/94619] " daniel.kruegler at googlemail dot com 2020-08-25 14:34 ` samestimable2016 at gmail dot com 2021-08-05 4:46 ` pinskia at gcc dot gnu.org
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-94619-4@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).