public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102034] New: template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template
@ 2021-08-24  9:37 nickhuang99 at hotmail dot com
  2021-08-24  9:42 ` [Bug c++/102034] " pinskia at gcc dot gnu.org
  2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: nickhuang99 at hotmail dot com @ 2021-08-24  9:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102034

            Bug ID: 102034
           Summary: template function signature incorrectly drops
                    top-level cv-qualifiers of parameter from
                    typedef-array of template-template
           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: ---

Even the following snippet of code has similar root cause as PR101402 and
PR102033, it cannot be easy fixed even with simple improvement of
*resolve_typename_type*. It seems that we need a re-work of this function to
correctly do recursion.

template<class TA>
struct A{
        template<class TB>
        struct B{
        typedef TB Arr3[3];
        };
};
template<class TA, class TB>
void f(const typename A<TA>::template B<TB>::Arr3){}
template <>
void f<int, char>(const typename A<int>::template B<char>::Arr3){}

error: template-id 'f<int, char>' for 'void f(const char*)' does not match any
template declaration
   11 | void f<int, char>(const typename A<int>::template B<char>::Arr3){}
      |      ^~~~~~~~~~~~
template-template.cpp:9:6: note: candidate is: 'template<class TA, class TB>
void f(typename A<TA>::B<TB>::Arr3)'
    9 | void f(const typename A<TA>::template B<TB>::Arr3){}
      |      ^

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/102034] template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template
  2021-08-24  9:37 [Bug c++/102034] New: template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template nickhuang99 at hotmail dot com
@ 2021-08-24  9:42 ` pinskia at gcc dot gnu.org
  2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-24  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102034

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is definitely the same as PR 102033.  The array is decaying to a const
char* and then not matching.

*** This bug has been marked as a duplicate of bug 102033 ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/102034] template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template
  2021-08-24  9:37 [Bug c++/102034] New: template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template nickhuang99 at hotmail dot com
  2021-08-24  9:42 ` [Bug c++/102034] " pinskia at gcc dot gnu.org
@ 2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org
  1 sibling, 0 replies; 3+ 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=102034

--- Comment #2 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] 3+ messages in thread

end of thread, other threads:[~2021-10-15 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24  9:37 [Bug c++/102034] New: template function signature incorrectly drops top-level cv-qualifiers of parameter from typedef-array of template-template nickhuang99 at hotmail dot com
2021-08-24  9:42 ` [Bug c++/102034] " pinskia at gcc dot gnu.org
2021-10-15 21:00 ` cvs-commit 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).