public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115356] New: not a constant expression can be used as non-type template argument inside requires expression
@ 2024-06-05 12:28 fchelnokov at gmail dot com
  2024-06-05 15:23 ` [Bug c++/115356] a reference to a non-constant integer " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2024-06-05 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

* [Bug c++/115356] a reference to a non-constant integer expression can be used as non-type template argument inside requires expression
  2024-06-05 12:28 [Bug c++/115356] New: not a constant expression can be used as non-type template argument inside requires expression fchelnokov at gmail dot com
@ 2024-06-05 15:23 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-05 15:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-06-05
     Ever confirmed|0                           |1
            Summary|not a constant expression   |a reference to a
                   |can be used as non-type     |non-constant integer
                   |template argument inside    |expression can be used as
                   |requires expression         |non-type template argument
                   |                            |inside requires expression
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
A const reference has the same issue as rvalue reference.

Confirmed.

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

end of thread, other threads:[~2024-06-05 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05 12:28 [Bug c++/115356] New: not a constant expression can be used as non-type template argument inside requires expression fchelnokov at gmail dot com
2024-06-05 15:23 ` [Bug c++/115356] a reference to a non-constant integer " pinskia 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).