Bug 81139 - Non-deduced return type in abbreviated function template
Summary: Non-deduced return type in abbreviated function template
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2017-06-20 14:34 UTC by Andrew Sutton
Modified: 2021-08-13 08:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-06-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Sutton 2017-06-20 14:34:21 UTC
When a constrained-type-specifier is the same as that of a parameter type, the return type is not deduced. 


template<typename T> concept bool C = true;

C f(C) { return 0; }

void g() {
  auto x = f("x");
  static_assert(std::is_same<decltype(x), int>::value);
}

The static assertion should fail.
Comment 1 Tom Honermann 2017-06-24 12:03:38 UTC
Bug 69448 appears to be related.
Comment 2 Andrew Pinski 2021-08-13 08:52:57 UTC
Is this true?

With the following updated C++20 testcase, clang, GCC and MSVC all cause the static_assert to pass:
#include <type_traits>

template<typename T> concept C = true;

C auto f(C auto) { return 0; }

void g() {
  auto x = f("x");
  static_assert(std::is_same<decltype(x), int>::value);
}