Bug 55588 - Failure to diagnose non-template-id prefixed by keyword template
Summary: Failure to diagnose non-template-id prefixed by keyword template
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords: accepts-invalid, deferred, diagnostic
: 45975 89978 96321 113375 (view as bug list)
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2012-12-04 09:05 UTC by Jonathan Wakely
Modified: 2024-01-13 23:25 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-09-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2012-12-04 09:05:57 UTC
This example is taken from 14.2 [temp.names] p5

template <class T> struct A {
  void f(int);
  template <class U> void f(U);
};
template <class T> void f(T t) {
  A<T> a;
  a.template f<>(t);  // OK: calls template
  a.template f(t);    // error: not a template-id
}

G++ compiles it without error (as does Clang++, but not Comeau online)
Comment 1 Jonathan Wakely 2012-12-04 09:14:02 UTC
I should have added an instantiation of the function to the code:


template <class T> struct A {
  void f(int);
  template <class U> void f(U);
};
template <class T> void f(T t) {
  A<T> a;
  a.template f<>(t); // OK: calls template
  a.template f(t);  // error: not a template-id
}

int main() {
  f(1);
}
Comment 2 Ville Voutilainen 2013-10-20 14:09:01 UTC
Also present in 4.9 trunk, and I recently got a user complaint about this bug. How can I upvote? :)
Comment 3 Eric Gallager 2017-08-21 14:47:19 UTC
Confirmed.
Comment 4 Eric Gallager 2018-09-18 05:37:33 UTC
(In reply to Ville Voutilainen from comment #2)
> Also present in 4.9 trunk, and I recently got a user complaint about this
> bug. How can I upvote? :)

If Bug 86315 is fixed, adding yourself on cc will become kinda like upvoting, so since you've already added yourself on cc, you've already upvoted.
Comment 5 Jonathan Wakely 2018-09-18 09:01:40 UTC
G++ and Clang still accept this, EDG still rejects it.
Comment 6 Eric Gallager 2019-09-18 17:26:53 UTC
(In reply to Eric Gallager from comment #4)
> (In reply to Ville Voutilainen from comment #2)
> > Also present in 4.9 trunk, and I recently got a user complaint about this
> > bug. How can I upvote? :)
> 
> If Bug 86315 is fixed, 

update: this has happened.
Comment 7 Jonathan Wakely 2019-09-23 10:24:41 UTC
G++ and Clang still accept this, EDG doesn't. The example in [temp.names] is unchanged, so this should still be rejected.
Comment 8 Marek Polacek 2020-04-11 15:16:56 UTC
This is CWG 96.  Too late for GCC 10 but I'll take a look in GCC 11.
Comment 9 Andrew Pinski 2021-08-23 08:12:04 UTC
*** Bug 89978 has been marked as a duplicate of this bug. ***
Comment 10 Andrew Pinski 2021-08-23 08:12:26 UTC
*** Bug 96321 has been marked as a duplicate of this bug. ***
Comment 11 Andrew Pinski 2021-08-23 08:12:33 UTC
*** Bug 45975 has been marked as a duplicate of this bug. ***
Comment 12 Andrew Pinski 2024-01-13 23:25:25 UTC
*** Bug 113375 has been marked as a duplicate of this bug. ***