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

Reply via email to