public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100716] New: member function template parameter not printed in candidate list
@ 2021-05-21 15:21 kretz at kde dot org
  2021-05-21 15:53 ` [Bug c++/100716] " kretz at kde dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kretz at kde dot org @ 2021-05-21 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100716
           Summary: member function template parameter not printed in
                    candidate list
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org
                CC: paolo.carlini at oracle dot com
  Target Milestone: ---

template<typename T>
  struct A {
    template<typename U>
      void f() { }
  };

int main() {
  A<void>().f(0);
}

With -fpretty-templates this prints:

<source>: In function 'int main()':
<source>:8:6: error: no matching function for call to 'A<void>::f(int)'
<source>:4:12: note: candidate: 'template<class U> void A<T>::f() [with U = U;
T = void]'
[...]

>From the diagnostics, it is not apparent what entity U applies to. Also 'with U
= U' is unnecessary noise. It should be:

<source>:4:12: note: candidate: 'template<class U> void A<T>::f<U>() [with T =
void]'

However,

template<typename T>
  struct A {
    template<typename U>
      void f(U) { }
  };

int main() {
  A<void>().f();
}

doesn't need to show the function template parameter and should be diagnosed
as:

<source>:4:12: note: candidate: 'template<class U> void A<T>::f(U) [with T =
void]'

However, to distinguish the two cases, cp/error.c would need to determine
whether the function template parameters are deducible. Alternatively, it would
have to look at the list of function parameters and check whether all template
parameters are used somehow (even if not deducible). Not sure whether that's
worth the effort. I assume the current behavior was chosen because the majority
of function template parameters are deducible?

FWIW, I believe the fix for PR50828 was incorrect since it removes the ability
to control whether dump_template_parms called from dump_function_decl returns
early for primary templates or not. I think the flags need to be modified for
printing the function's scope, but not for dump_function_decl.

I'll try to come up with a patch.

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

end of thread, other threads:[~2021-07-22  8:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 15:21 [Bug c++/100716] New: member function template parameter not printed in candidate list kretz at kde dot org
2021-05-21 15:53 ` [Bug c++/100716] " kretz at kde dot org
2021-05-25 18:50 ` kretz at kde dot org
2021-05-27  6:04 ` [Bug c++/100716] member function template parameter should never be printed in candidate list and "T = T" should never be shown in substitutions kretz at kde dot org
2021-05-27 21:01 ` cvs-commit at gcc dot gnu.org
2021-07-22  8:28 ` mkretz 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).