public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result
@ 2022-08-24 13:26 jakob at schmutz dot co.uk
  2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakob at schmutz dot co.uk @ 2022-08-24 13:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106734

            Bug ID: 106734
           Summary: [requires] std::same_as in compound requirements
                    doesn't produce expected result
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakob at schmutz dot co.uk
  Target Milestone: ---

On gcc version 12.2.0 (and 11.3.0) I would expect the following code


```
#include <iostream>

struct Bar {
};

int main()
{
    Bar bar;
    constexpr bool same = requires
    {
        { bar } -> std::same_as<Bar>;
    };

    constexpr bool conv = requires
    {
        { bar } -> std::convertible_to<Bar>;
    };

    if constexpr (std::same_as<decltype(bar), Bar>)
    {
        std::cout << "AS SAME" << std::endl;
    }

    if constexpr (std::is_same_v<decltype(bar), Bar>)
    {
        std::cout << "IS SAME" << std::endl;
    }

    if constexpr (same)
    {
        std::cout << "REQUIRES SAME" << std::endl;
    }

    if constexpr (conv)
    {
        std::cout << "CONVERTIBLE" << std::endl;
    }

    return 0;
}
```

to return

```
AS SAME
IS SAME
REQUIRES SAME
CONVERTIBLE
```

based on how how [compound
requires](https://en.cppreference.com/w/cpp/language/requires) section reads


but instead it returns

```
IS SAME
REQUIRES SAME
CONVERTIBLE
```

compiled with `g++ temp.cpp -std=c++20`

compiling with `clang++ temp.cpp -std=c++20` produces the expected output

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-08-24 14:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 13:26 [Bug c++/106734] New: [requires] std::same_as in compound requirements doesn't produce expected result jakob at schmutz dot co.uk
2022-08-24 13:28 ` [Bug c++/106734] " jakob at schmutz dot co.uk
2022-08-24 13:36 ` jakob at schmutz dot co.uk
2022-08-24 14:00 ` redi at gcc dot gnu.org
2022-08-24 14:17 ` jakob at schmutz dot co.uk
2022-08-24 14:21 ` jakob at schmutz dot co.uk
2022-08-24 14:25 ` jakob at schmutz dot co.uk
2022-08-24 14:27 ` redi 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).