[Bug libstdc++/96922] New: primary expression error when using parenthesis around requires expression for some concepts

rene.rahn@fu-berlin.de gcc-bugzilla@gcc.gnu.org
Thu Sep 3 13:46:09 GMT 2020


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.


More information about the Gcc-bugs mailing list