public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts
@ 2020-09-03 13:46 rene.rahn@fu-berlin.de
  2020-09-03 13:47 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rene.rahn@fu-berlin.de @ 2020-09-03 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96922
           Summary: primary expression error when using parenthesis around
                    requires expression for some concepts
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rene.rahn@fu-berlin.de
  Target Milestone: ---

Hi GCC team, 

I found a strange behavior when using c++17 mode with -fconcepts on gcc 10 as
well as gcc 9. Basically, if we use a concept that uses variadic templates then
the compiler emits a primary expression error when putting parenthesis around
the requires expression. This does not happen if we leave the parenthesis away
or if the concept does not use variadic templates.

Here the example I ran into (https://godbolt.org/z/95d4Y3):
```cpp
#include <type_traits>

// Not working for concepts with variadic templates
template <typename t, typename ...args_t>
concept constructible_from = std::is_constructible_v<t, args_t...>;

template <typename t>
    requires (constructible_from<t>) // does not work with parenthesis
void foo();

template <typename t>
    requires constructible_from<t> // works without parenthesis
void bar();

// Working without variadic templates
template <typename t, typename u>
concept constructible_from_one = std::is_constructible_v<t, u>;

template <typename t>
    requires (constructible_from_one<t, t>) 
void foo();

```

Thank you very much for your help.

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

* [Bug libstdc++/96922] primary expression error when using parenthesis around requires expression for some concepts
  2020-09-03 13:46 [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts rene.rahn@fu-berlin.de
@ 2020-09-03 13:47 ` rene.rahn@fu-berlin.de
  2020-09-03 14:31 ` [Bug c++/96922] " redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rene.rahn@fu-berlin.de @ 2020-09-03 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Rene Rahn <rene.rahn@fu-berlin.de> ---
Also note, that this does not happen in c++20 mode using gcc-10.2 (see link to
compiler explorer).

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

* [Bug c++/96922] primary expression error when using parenthesis around requires expression for some concepts
  2020-09-03 13:46 [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts rene.rahn@fu-berlin.de
  2020-09-03 13:47 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
@ 2020-09-03 14:31 ` redi at gcc dot gnu.org
  2020-09-03 16:05 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
  2020-09-03 19:30 ` [Bug c++/96922] " redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-03 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-09-03
           Keywords|                            |rejects-valid
          Component|libstdc++                   |c++
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is nothing to do with libstdc++, changing component to c++.

Reduced:

template<typename...> struct trait { static constexpr bool value = true; };

// Not working for concepts with variadic templates
template <typename t, typename ...args_t>
concept constructible_from = trait<t, args_t...>::value;

template <typename t>
    requires (constructible_from<t>) // does not work with parenthesis
void foo();

template <typename t>
    requires constructible_from<t> // works without parenthesis
void bar();

// Working without variadic templates
template <typename t, typename u>
concept constructible_from_one = trait<t, u>::value;

template <typename t>
    requires (constructible_from_one<t, t>) 
void foo();

Compiles with -std=c++20 but not -std=c++17 -fconcepts

I don't see anything in the Concepts TS grammar which would make this invalid.

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

* [Bug libstdc++/96922] primary expression error when using parenthesis around requires expression for some concepts
  2020-09-03 13:46 [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts rene.rahn@fu-berlin.de
  2020-09-03 13:47 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
  2020-09-03 14:31 ` [Bug c++/96922] " redi at gcc dot gnu.org
@ 2020-09-03 16:05 ` rene.rahn@fu-berlin.de
  2020-09-03 19:30 ` [Bug c++/96922] " redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rene.rahn@fu-berlin.de @ 2020-09-03 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

Rene Rahn <rene.rahn@fu-berlin.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++

--- Comment #3 from Rene Rahn <rene.rahn@fu-berlin.de> ---
> This is nothing to do with libstdc++, changing component to c++.

Sorry, I thought I selected c++. Thank you for correcting this.

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

* [Bug c++/96922] primary expression error when using parenthesis around requires expression for some concepts
  2020-09-03 13:46 [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts rene.rahn@fu-berlin.de
                   ` (2 preceding siblings ...)
  2020-09-03 16:05 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
@ 2020-09-03 19:30 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-03 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You've just changed it back again to libstdc++!

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

end of thread, other threads:[~2020-09-03 19:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 13:46 [Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts rene.rahn@fu-berlin.de
2020-09-03 13:47 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
2020-09-03 14:31 ` [Bug c++/96922] " redi at gcc dot gnu.org
2020-09-03 16:05 ` [Bug libstdc++/96922] " rene.rahn@fu-berlin.de
2020-09-03 19:30 ` [Bug c++/96922] " redi 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).