public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111712] New: Syntax error when passing function parameter as NTTP in requires-clause
@ 2023-10-06  5:31 hewillk at gmail dot com
  2023-10-06  9:03 ` [Bug c++/111712] " pinskia at gcc dot gnu.org
  2023-10-06 13:42 ` ppalka at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: hewillk at gmail dot com @ 2023-10-06  5:31 UTC (permalink / raw)
  To: gcc-bugs

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()>; };
      |                                                       ^

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

* [Bug c++/111712] Syntax error when passing function parameter as NTTP in requires-clause
  2023-10-06  5:31 [Bug c++/111712] New: Syntax error when passing function parameter as NTTP in requires-clause hewillk at gmail dot com
@ 2023-10-06  9:03 ` pinskia at gcc dot gnu.org
  2023-10-06 13:42 ` ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-06  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-06
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
template<bool B>
struct s
{
  constexpr static bool t = B;
  constexpr bool operator()() { return t; }
};

template<bool B>
void f(s<B> b)
  requires requires { typename s<b()>; };

int main() {
  f(s<true>{});
}
```

Note MSVC accepts the above ...

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

* [Bug c++/111712] Syntax error when passing function parameter as NTTP in requires-clause
  2023-10-06  5:31 [Bug c++/111712] New: Syntax error when passing function parameter as NTTP in requires-clause hewillk at gmail dot com
  2023-10-06  9:03 ` [Bug c++/111712] " pinskia at gcc dot gnu.org
@ 2023-10-06 13:42 ` ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-10-06 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
this seems to be a dup of PR104255, using a trailing requires instead of a
trailing return type

*** This bug has been marked as a duplicate of bug 104255 ***

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

end of thread, other threads:[~2023-10-06 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06  5:31 [Bug c++/111712] New: Syntax error when passing function parameter as NTTP in requires-clause hewillk at gmail dot com
2023-10-06  9:03 ` [Bug c++/111712] " pinskia at gcc dot gnu.org
2023-10-06 13:42 ` ppalka 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).