public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires
@ 2022-11-10 8:06 jlame646 at gmail dot com
2022-11-10 12:05 ` [Bug c++/107605] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jlame646 at gmail dot com @ 2022-11-10 8:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
Bug ID: 107605
Summary: GCC rejects valid program involving std::bind and
requires
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following valid program(afaik) is rejected by gcc but accepted by clang.
Demo: https://godbolt.org/z/bdMfKE41n
```
template <typename T>
class myclass {
public:
void func(const T&) requires true
{
std::cout << "true";
}
void func(const T&) requires false
{
std::cout << "false";
}
};
int main(){
myclass<int> obj;
auto mylambda = std::bind(&myclass<int>::func, &obj, 5); //accepted by clang
rejected by gcc
mylambda();
}
```
The error says:
```
error: no matching function for call to 'bind(<unresolved overloaded function
type>, myclass<int>*, int)'
24 | auto mylambda = std::bind(&myclass<int>::func, &obj, 5); //accepted
by clang rejected by gcc
```
This has been discussed here:
https://stackoverflow.com/questions/74385849/clang-accepts-program-involving-requires-constraint-while-gcc-and-msvc-rejects-i
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/107605] GCC rejects valid program involving std::bind and requires
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
@ 2022-11-10 12:05 ` redi at gcc dot gnu.org
2022-11-10 12:50 ` [Bug c++/107605] GCC rejects valid program involving requires-clause jlame646 at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-10 12:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |rejects-valid
Ever confirmed|0 |1
Last reconfirmed| |2022-11-10
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This has nothing to do with std::bind.
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;
req.C:18:32: error: unable to deduce ‘auto’ from ‘& myclass<int>::func’
18 | auto mylambda = &myclass<int>::func;
| ^~~~
req.C:18:32: note: couldn’t deduce template parameter ‘auto’
I think there's an existing bug about this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/107605] GCC rejects valid program involving requires-clause
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
2022-11-10 12:05 ` [Bug c++/107605] " redi at gcc dot gnu.org
@ 2022-11-10 12:50 ` jlame646 at gmail dot com
2022-11-10 13:49 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jlame646 at gmail dot com @ 2022-11-10 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
Jason Liam <jlame646 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|GCC rejects valid program |GCC rejects valid program
|involving std::bind and |involving requires-clause
|requires |
--- Comment #2 from Jason Liam <jlame646 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> This has nothing to do with std::bind.
>
Yes i know this has nothing to do with `std::bind`. For example, I created the
following demo that reproduces the same error without std::bind. See demo:
https://godbolt.org/z/K6jKqsGx5 . I also mentioned the same in one of my
comments here:
https://stackoverflow.com/questions/74385849/clang-accepts-program-involving-requires-constraint-while-gcc-and-msvc-rejects-i/74386905#comment131319278_74385849
. I've edited the title of this bug.
```
template <typename T>
class myclass {
public:
void func(const T&) requires true
{
std::cout << "true";
}
void func(const T&) requires false
{
std::cout << "false";
}
};
template<typename T>
void bar(T&& )
{
}
int main(){
myclass<int> obj;
bar(&myclass<int>::func); //accepted by clang but rejected by gcc and msvc
}
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/107605] GCC rejects valid program involving requires-clause
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
2022-11-10 12:05 ` [Bug c++/107605] " redi at gcc dot gnu.org
2022-11-10 12:50 ` [Bug c++/107605] GCC rejects valid program involving requires-clause jlame646 at gmail dot com
@ 2022-11-10 13:49 ` redi at gcc dot gnu.org
2022-11-10 23:15 ` [Bug c++/107605] constraint on a member function does causes ambigious and not allowing forming a pointer to the function pinskia at gcc dot gnu.org
2022-11-10 23:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-10 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jason Liam from comment #2)
> Yes i know this has nothing to do with `std::bind`.
OK, good. You reported a bug with std::bind in the title, and std::bind in the
example. I'm providing the necessary analysis in the bug report and a reduced
example. You don't need to get defensive about it.
For example, I created
> the following demo that reproduces the same error without std::bind. See
> demo: https://godbolt.org/z/K6jKqsGx5
Nice. That wasn't provided in the bug report. So I added the information here.
If you don't want us to analyse your bug report and add detail to it, don't
bother reporting it!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/107605] constraint on a member function does causes ambigious and not allowing forming a pointer to the function
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
` (2 preceding siblings ...)
2022-11-10 13:49 ` redi at gcc dot gnu.org
@ 2022-11-10 23:15 ` pinskia at gcc dot gnu.org
2022-11-10 23:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-10 23:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks|101603 |
Summary|GCC rejects valid program |constraint on a member
|involving requires-clause |function does causes
| |ambigious and not allowing
| |forming a pointer to the
| |function
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
At first I thought it was a pointer to member function issue but nope it is not
as the following happens too but we need to have have the class as a template
rather than the function:
extern "C" int puts(const char*);
template <typename T>
class myclass {
public:
static void func(const T&) requires true
{
puts("true");
}
static void func(const T&) requires false
{
puts("false");
}
};
auto mylambda = &myclass<int>::func;
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101603
[Bug 101603] [meta-bug] pointer to member functions issues
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/107605] constraint on a member function does causes ambigious and not allowing forming a pointer to the function
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
` (3 preceding siblings ...)
2022-11-10 23:15 ` [Bug c++/107605] constraint on a member function does causes ambigious and not allowing forming a pointer to the function pinskia at gcc dot gnu.org
@ 2022-11-10 23:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-10 23:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107605
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Summary|constraint on a member |constraint on a member
|function gives ambiguous |function does causes
|error when forming a |ambigious and not allowing
|pointer to the function |forming a pointer to the
| |function
Status|NEW |RESOLVED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 80637.
*** This bug has been marked as a duplicate of bug 80637 ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-10 23:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 8:06 [Bug c++/107605] New: GCC rejects valid program involving std::bind and requires jlame646 at gmail dot com
2022-11-10 12:05 ` [Bug c++/107605] " redi at gcc dot gnu.org
2022-11-10 12:50 ` [Bug c++/107605] GCC rejects valid program involving requires-clause jlame646 at gmail dot com
2022-11-10 13:49 ` redi at gcc dot gnu.org
2022-11-10 23:15 ` [Bug c++/107605] constraint on a member function does causes ambigious and not allowing forming a pointer to the function pinskia at gcc dot gnu.org
2022-11-10 23:20 ` pinskia 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).