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

            Bug ID: 111712
           Summary: Syntax error when passing function parameter as NTTP
                    in requires-clause
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

Regardless of whether the code is well-formed or not, this should be valid
syntax

https://godbolt.org/z/4qM9nG4WP

#include <type_traits>

template<bool B>
void f(std::bool_constant<B> b)
  requires requires { typename std::bool_constant<b()>; };

int main() {
  f(std::true_type{});
}

However, GCC givs

<source>:5:54: error: template argument 1 is invalid
<source>:5:37: error: invalid use of template-name 'std::bool_constant' without
an argument list
    5 |   requires requires { typename std::bool_constant<b()>; };
      |                                     ^~~~~~~~~~~~~
In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20231005/include/c++/14.0.0/type_traits:120:11:
note: 'template<bool __v> using std::bool_constant = std::__bool_constant<__v>'
declared here
  120 |     using bool_constant = __bool_constant<__v>;
      |           ^~~~~~~~~~~~~
<source>:5:50: error: expected '(' before '<' token
    5 |   requires requires { typename std::bool_constant<b()>; };
      |                                                  ^
      |                                                  (
<source>:5:55: error: expected primary-expression before ';' token
    5 |   requires requires { typename std::bool_constant<b()>; };
      |                                                       ^

Reply via email to