Bug 80637 - constraint on a member function does causes ambigious and not allowing forming a pointer to the function
Summary: constraint on a member function does causes ambigious and not allowing formin...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: c++-concepts
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 107605 (view as bug list)
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2017-05-05 00:55 UTC by ryan.burn
Modified: 2023-03-15 13:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-11-10 00:00:00


Attachments
Updated full testcase (160 bytes, text/plain)
2022-06-21 18:03 UTC, Andrew Pinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ryan.burn 2017-05-05 00:55:14 UTC
This code won't compile with GCC

/////////////////////////////////////////////////////
template <class T>
struct A {
  void f() 
    requires std::is_same_v<T, int>
  {
  }

  void f(int) 
    requires !std::is_same_v<T, int>
  {
  }
};

int main() {
  auto fptr = &A<int>::f;
  return 0;
}
/////////////////////////////////////////////////////

According to the discussion here, it should be valid:

http://stackoverflow.com/q/43793941/4447365
Comment 1 Andrew Pinski 2022-06-21 18:03:44 UTC
Created attachment 53185 [details]
Updated full testcase
Comment 2 Andrew Pinski 2022-06-21 18:04:23 UTC
clang accepts this while MSVC rejects this for the same reason as GCC.
Comment 3 Andrew Pinski 2022-11-10 23:20:26 UTC
*** Bug 107605 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2022-11-10 23:21:38 UTC
Reduced testcase from the dup bug:

extern "C" int puts(const char*);

template <typename T>
class myclass {
public:

  void func(const T&) requires true
  {
     puts("true");
  }
 
  void func(const T&) requires false
  {
     puts("false");
  }
};                                                                              

auto mylambda = &myclass<int>::func;
Comment 5 Andrew Pinski 2022-11-10 23:24:30 UTC
(In reply to Andrew Pinski from comment #4)
> Reduced testcase from the dup bug:

Oh MSVC still rejects this reduced testcase for the same reason as GCC.
<source>(19): error C3535: cannot deduce type for 'auto' from 'overloaded-function'