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

            Bug ID: 115356
           Summary: not a constant expression can be used as non-type
                    template argument inside requires expression
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program

```
template <int>
struct A {};

constexpr bool foo(int v) {
     int && x = int{v};
     return requires { 
        typename A<x>;
        typename A<x>::T;
    };
}

static_assert( foo(1) );
```

is rejected in Clang and MSVC, because `x` is not initialized by a constant
expression and because there is no type `A<1>::T`, but GCC accepts the program
just fine. Online demo: https://gcc.godbolt.org/z/o9oEee5ve

Reply via email to