public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102042] New: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function
@ 2021-08-24 13:57 nickhuang99 at hotmail dot com
2021-08-24 14:41 ` [Bug c++/102042] " nickhuang99 at hotmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-24 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042
Bug ID: 102042
Summary: specialization after instantiation error possibly
rooted from mis-calculating template function
signature of parameter of array of template function
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nickhuang99 at hotmail dot com
Target Milestone: ---
I suspect this is from similar root cause of PR101402, PR102033, PR102034 etc.
when incorrectly dropping top-level cv-qualifier during calculating template
function declarator of which parameter is an array of template function
pointer.
Clearly from "#2" of static assert, GCC already gets correct specialization
"g<1,int>" signature, still the last statement of specialization declaration
causes error with very strange error message.
clang(https://www.godbolt.org/z/5eM5b4GjG) accepts.
MSVC++(https://www.godbolt.org/z/3x9dvsfTh) stumbles like GCC, but a better
clear clue.
#include<type_traits>
template<unsigned int N, class T>
void f(const T[N]){}
template<unsigned int N, class T>
using fPtr=decltype(f<N,T>)*;
template<unsigned int N, class T>
fPtr<N,T> af[N]={&f<N,T>}; // even without initialization,error still is
template<unsigned int N, class T>
void g(const decltype(af<N,T>)&){}
static_assert(std::is_same<decltype(af<1,int>),
fPtr<1,int>[1] >::value, "af is correct"); // #1
static_assert(std::is_same<decltype(g<1,int>),
void(fPtr<1,int>const(&)[1])>::value, "fun"); // #2
template<>
void g<1,int>(fPtr<1,int>const(&)[1]){}
GCC gives very misleading error message:
error: specialization of 'void g(decltype (af<N, T>)&) [with unsigned int N =
1; T = int; decltype (af<N, T>) = void (* [1])(const int*)]' after
instantiation
21 | void g<1,int>(fPtr<1,int>const(&)[1]){}
| ^
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102042] specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function
2021-08-24 13:57 [Bug c++/102042] New: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function nickhuang99 at hotmail dot com
@ 2021-08-24 14:41 ` nickhuang99 at hotmail dot com
2021-08-24 15:16 ` nickhuang99 at hotmail dot com
2021-08-24 15:29 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-24 14:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042
--- Comment #1 from qingzhe huang <nickhuang99 at hotmail dot com> ---
Slightly change the prototype of "g" from reference to pointer, you have exact
same error. (please note #0 changes to pointer type)
#include<type_traits>
template<unsigned int N, class T>
void f(const T[N]){}
template<unsigned int N, class T>
using fPtr=decltype(f<N,T>)*;
template<unsigned int N, class T>
fPtr<N,T> af[N]={&f<N,T>};
template<unsigned int N, class T>
void g(const decltype(af<N,T>)*){} // #0
static_assert(std::is_same<decltype(g<1,int>),
void(const fPtr<1,int>(*)[1])>::value, "fun"); // #2
template<>
void g<1,int>(const fPtr<1,int>(*)[1]){}
error: specialization of 'void g(decltype (af<N, T>)*) [with unsigned int N =
1; T = int; decltype (af<N, T>) = void (* [1])(const int*)]' after
instantiation
24 | void g<1,int>(const fPtr<1,int>(*)[1]){}
|
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102042] specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function
2021-08-24 13:57 [Bug c++/102042] New: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function nickhuang99 at hotmail dot com
2021-08-24 14:41 ` [Bug c++/102042] " nickhuang99 at hotmail dot com
@ 2021-08-24 15:16 ` nickhuang99 at hotmail dot com
2021-08-24 15:29 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-24 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042
--- Comment #2 from qingzhe huang <nickhuang99 at hotmail dot com> ---
Just tested with my fix, it can be fixed with my suggested patch in PR102033.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102042] specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function
2021-08-24 13:57 [Bug c++/102042] New: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function nickhuang99 at hotmail dot com
2021-08-24 14:41 ` [Bug c++/102042] " nickhuang99 at hotmail dot com
2021-08-24 15:16 ` nickhuang99 at hotmail dot com
@ 2021-08-24 15:29 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-24 15:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another dup then. Your patch should include this as a testcase too (and should
be submitted to the mailing list).
*** This bug has been marked as a duplicate of bug 102033 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-24 15:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 13:57 [Bug c++/102042] New: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function nickhuang99 at hotmail dot com
2021-08-24 14:41 ` [Bug c++/102042] " nickhuang99 at hotmail dot com
2021-08-24 15:16 ` nickhuang99 at hotmail dot com
2021-08-24 15:29 ` redi at gcc dot gnu.org
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).