Bug 70544 - Overload resolution with explicitly specified template arguments
Summary: Overload resolution with explicitly specified template arguments
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2016-04-05 08:59 UTC by Roman Perepelitsa
Modified: 2022-01-25 03:01 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.2.0, 11.1.0
Known to fail: 10.1.0, 9.4.0
Last reconfirmed: 2021-08-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Perepelitsa 2016-04-05 08:59:05 UTC
When compiling this program:

  template <class... Args>
  void F(Args&&...);

  template <class T, class... Args>
  int F(Args&&...);

  int main() {
    int{F<int>(0)};
  }

Expected behavior: compile error (call to `F` is ambiguous).
Actual behaviour: compiles successfully.

Comment from Richard Smith: "I suspect this might be fallout from GCC's workaround for core issue 1395 (after substituting explicitly-specified template arguments, the first 'F' has one pack element deduced and the second 'F' has none, so I suspect the second may look more specialized under GCC's approach to 1395 but not Clang's)."

Note that the following program gets rejected by GCC (as expected):

  template <class T>
  void F(T);

  template <class T, class U>
  void F(U);

  int main() {
    F<int>(0);
  }
Comment 1 Andrew Pinski 2021-08-23 07:43:24 UTC
Seems Fixed in GCC 10.2.0 and GCC 11+
Comment 2 Martin Liška 2021-12-09 09:03:39 UTC
Fixed with r11-1571-g57b4daf8dc4ed7b6.