public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer
@ 2021-08-24 14:28 nickhuang99 at hotmail dot com
2021-08-24 22:04 ` [Bug c++/102044] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-24 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102044
Bug ID: 102044
Summary: another case of template function signature
incorrectly dropping top-level cv-qualifier with
function parameter of array of template function
pointer
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: ---
This may be dup case of PR102033, PR102034 and very probably not related with
PR102042 of which I just changed the function parameter of "g" to const array
instead of const reference of array. So, it can be another test case.
However, clang(https://www.godbolt.org/z/fxzoWK4G8) passes,
MSVC++(https://www.godbolt.org/z/c7Pfbr6b9) fails like GCC. In this sense, I
believe this case might be different from all above cases because MSVC++ does
not fail.
consider:
#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>)){}
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(const fPtr<1,int>[1])>::value, "fun"); // #2
template<>
void g<1,int>(const fPtr<1,int>[1]){}
GCC says:
error: template-id 'g<1, int>' for 'void g(void (* const*)(const int*))' does
not match any template declaration
21 | void g<1,int>(const fPtr<1,int>[1]){}
| ^~~~~~~~
fun-array-value.cpp:12:6: note: candidate is: 'template<unsigned int N, class
T> void g(decltype (af<N, T>))'
12 | void g(const decltype(af<N,T>)){}
| ^
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102044] another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer
2021-08-24 14:28 [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer nickhuang99 at hotmail dot com
@ 2021-08-24 22:04 ` pinskia at gcc dot gnu.org
2021-08-26 11:09 ` nickhuang99 at hotmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-24 22:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102044
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |24666
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This looks like another case where arrays are not decaying correctly; either
too soon or too late.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24666
[Bug 24666] [meta-bug] array decaying to pointers
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102044] another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer
2021-08-24 14:28 [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer nickhuang99 at hotmail dot com
2021-08-24 22:04 ` [Bug c++/102044] " pinskia at gcc dot gnu.org
@ 2021-08-26 11:09 ` nickhuang99 at hotmail dot com
2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
2021-10-25 9:01 ` nickhuang99 at hotmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-26 11:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102044
--- Comment #2 from qingzhe huang <nickhuang99 at hotmail dot com> ---
The root cause of this issue maybe similar to those PR102033, PR102034,
PR102042 etc., however, this is still a distinctive case because of its nature.
It is not a "typename" indicating its a dependent-type, rather using
"decltype".
So, in this sense, to tackle this issue may need a different approach.
Currently I haven't found a similar function to resolve "decltype" type similar
to "resolve_typename_type". If anybody knows one, please let me know.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102044] another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer
2021-08-24 14:28 [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer nickhuang99 at hotmail dot com
2021-08-24 22:04 ` [Bug c++/102044] " pinskia at gcc dot gnu.org
2021-08-26 11:09 ` nickhuang99 at hotmail dot com
@ 2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
2021-10-25 9:01 ` nickhuang99 at hotmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-15 21:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102044
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:79802c5dcc043a515f429bb2bec7573b8537c32a
commit r12-4453-g79802c5dcc043a515f429bb2bec7573b8537c32a
Author: Jason Merrill <jason@redhat.com>
Date: Tue Sep 28 10:02:04 2021 -0400
c++: array cv-quals and template specialization [PR101402]
PRs 101402, 102033, etc. demonstrated that the fix for PR92010 wasn't
handling all cases of the CWG1001/1322 issue with parameter type qual
stripping and arrays with templates. The problem turned out to be in
determine_specialization, which did an extra substitution without the 92010
fix and then complained that the result didn't match.
But just removing that wrong/redundant code meant that we were accepting
specializations with different numbers of parameters, because the code in
fn_type_unification that compares types in this case wasn't checking for
length mismatch.
After fixing that, I realized that fn_type_unification couldn't tell the
difference between variadic and non-variadic function types, because the
args array doesn't include the terminal void we use to indicate
non-variadic
function type. So I added it, and made the necessary adjustments.
Thanks to qingzhe "nick" huang <nickhuang99@hotmail.com> for the patch that
led me to dig more into this, and the extensive testcases.
PR c++/51851
PR c++/101402
PR c++/102033
PR c++/102034
PR c++/102039
PR c++/102044
gcc/cp/ChangeLog:
* pt.c (determine_specialization): Remove redundant code.
(fn_type_unification): Check for mismatched length.
(type_unification_real): Ignore terminal void.
(get_bindings): Don't stop at void_list_node.
* class.c (resolve_address_of_overloaded_function): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/template/fnspec2.C: New test.
* g++.dg/template/parm-cv1.C: New test.
* g++.dg/template/parm-cv2.C: New test.
* g++.dg/template/parm-cv3.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102044] another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer
2021-08-24 14:28 [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer nickhuang99 at hotmail dot com
` (2 preceding siblings ...)
2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
@ 2021-10-25 9:01 ` nickhuang99 at hotmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-10-25 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102044
qingzhe huang <nickhuang99 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from qingzhe huang <nickhuang99 at hotmail dot com> ---
fixed by patch under PR101402
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-25 9:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 14:28 [Bug c++/102044] New: another case of template function signature incorrectly dropping top-level cv-qualifier with function parameter of array of template function pointer nickhuang99 at hotmail dot com
2021-08-24 22:04 ` [Bug c++/102044] " pinskia at gcc dot gnu.org
2021-08-26 11:09 ` nickhuang99 at hotmail dot com
2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
2021-10-25 9:01 ` nickhuang99 at hotmail dot com
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).