public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template
@ 2023-03-18  6:23 waffl3x at protonmail dot com
  2023-03-18  6:32 ` [Bug c++/109181] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: waffl3x at protonmail dot com @ 2023-03-18  6:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109181
           Summary: requires expression type requirement rejects valid
                    type when it is a nested member template
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: waffl3x at protonmail dot com
  Target Milestone: ---

https://godbolt.org/z/5hG9Eqhc9

struct A {
    template<typename>
    using B = int;
};

inline constexpr bool go = requires{typename A::template B<int>;};

error: 'typename A::B' names 'template<class> using B = int', which is not a
type

I believe this is not a regression as the bug exists all the way back to 10.1
(assuming I understand what regression means)

Clang and MSVC accept this code, I assume GCC is incorrect since I couldn't
find anything specifying that a member template is not allowed, however I also
haven't found anything that specifies that it is allowed so I am not certain.

The behavior exists in all versions I checked since GCC 10.1

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
@ 2023-03-18  6:32 ` pinskia at gcc dot gnu.org
  2023-03-18 19:34 ` waffl3x at protonmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-18  6:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-03-18
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.1.0, 12.1.0, 13.0,
                   |                            |6.1.0, 7.1.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Goes away the way back when -fconcepts support was originally added in GCC 6.
You can see that with this testcase:
```
struct A {
    template<typename>
    using B = int;
};

template<typename T>
bool go = requires{typename A::template B<T>;};
```

Note back in GCC 6, you needed `-std=c++17 -fconcepts` and also requires was
only allowed for templates too ..

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
  2023-03-18  6:32 ` [Bug c++/109181] " pinskia at gcc dot gnu.org
@ 2023-03-18 19:34 ` waffl3x at protonmail dot com
  2023-03-20 23:28 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: waffl3x at protonmail dot com @ 2023-03-18 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from waffl3x <waffl3x at protonmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed.
> Goes away the way back when -fconcepts support was originally added in GCC
> 6. You can see that with this testcase:
> ```
> struct A {
>     template<typename>
>     using B = int;
> };
> 
> template<typename T>
> bool go = requires{typename A::template B<T>;};
> ```
> 
> Note back in GCC 6, you needed `-std=c++17 -fconcepts` and also requires was
> only allowed for templates too ..

Ah damn, I'll try to keep in mind that I can use the old enabling flags to go
further back. I'm glad this one wasn't a duplicate, heres hoping I don't find
another bug today

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
  2023-03-18  6:32 ` [Bug c++/109181] " pinskia at gcc dot gnu.org
  2023-03-18 19:34 ` waffl3x at protonmail dot com
@ 2023-03-20 23:28 ` ppalka at gcc dot gnu.org
  2023-03-20 23:51 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-03-20 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
A workaround is to just remove the unneeded 'template' after the :: in this
case.  Or is there an example where the template keyword is needed that we
incorrectly reject?

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
                   ` (2 preceding siblings ...)
  2023-03-20 23:28 ` ppalka at gcc dot gnu.org
@ 2023-03-20 23:51 ` pinskia at gcc dot gnu.org
  2023-03-22  1:00 ` waffl3x at protonmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-20 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #3)
> A workaround is to just remove the unneeded 'template' after the :: in this
> case.  Or is there an example where the template keyword is needed that we
> incorrectly reject?

I could not find an example.

I did find an example where the template is removed clang rejects it but gcc
does not:
struct A {
    template<typename>
    using B = int;
};
template<typename T>
T C();

template<typename T>
bool go = requires{typename decltype(C<T>())::template B<T>;};

bool a = go<int>;

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
                   ` (3 preceding siblings ...)
  2023-03-20 23:51 ` pinskia at gcc dot gnu.org
@ 2023-03-22  1:00 ` waffl3x at protonmail dot com
  2023-08-08  2:53 ` waffl3x at protonmail dot com
  2023-08-09 18:10 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: waffl3x at protonmail dot com @ 2023-03-22  1:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from waffl3x <waffl3x at protonmail dot com> ---
(In reply to Patrick Palka from comment #3)
> A workaround is to just remove the unneeded 'template' after the :: in this
> case.  Or is there an example where the template keyword is needed that we
> incorrectly reject?

In my original use case, A in `inline constexpr bool go = requires{typename
A::template B<int>;};` would have been dependent, I included the template
keyword because of that but it should have occurred to me that the example I
presented doesn't need it, I'm not sure what the standard requires for this
sort of thing though.

When I reduce I just remove everything that isn't required to get the result
I'm looking for, I should have realized that changing the semantics of the
example might create confusion and in the future I think I will also include a
reduced version that comes closer to the problem I actually encountered, I
imagine that it will be helpful even if it's not actually the most reduced
version.

I'll try to create an example that reflects my use case better as soon as I
can.

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
                   ` (4 preceding siblings ...)
  2023-03-22  1:00 ` waffl3x at protonmail dot com
@ 2023-08-08  2:53 ` waffl3x at protonmail dot com
  2023-08-09 18:10 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: waffl3x at protonmail dot com @ 2023-08-08  2:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from waffl3x <waffl3x at protonmail dot com> ---
PR 110927 presents a similar use case that originally lead me to this bug, I
also posted the workarounds that I had since discovered there. If anyone coming
across this bug is looking for a solution you can find them there.

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

* [Bug c++/109181] requires expression type requirement rejects valid type when it is a nested member template
  2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
                   ` (5 preceding siblings ...)
  2023-08-08  2:53 ` waffl3x at protonmail dot com
@ 2023-08-09 18:10 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-08-09 18:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to waffl3x from comment #6)
> PR 110927 presents a similar use case that originally lead me to this bug, I
> also posted the workarounds that I had since discovered there. If anyone
> coming across this bug is looking for a solution you can find them there.

Interesting, thanks!  I'm going to call this PR a dup of the newer one then,
since that one has your workarounds.

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

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

end of thread, other threads:[~2023-08-09 18:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-18  6:23 [Bug c++/109181] New: requires expression type requirement rejects valid type when it is a nested member template waffl3x at protonmail dot com
2023-03-18  6:32 ` [Bug c++/109181] " pinskia at gcc dot gnu.org
2023-03-18 19:34 ` waffl3x at protonmail dot com
2023-03-20 23:28 ` ppalka at gcc dot gnu.org
2023-03-20 23:51 ` pinskia at gcc dot gnu.org
2023-03-22  1:00 ` waffl3x at protonmail dot com
2023-08-08  2:53 ` waffl3x at protonmail dot com
2023-08-09 18:10 ` 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).