[llvm-bugs] [Bug 49891] New: No hint to use -std=c++20 when using 'concept' or 'requires' with older -std modes

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 8 04:33:53 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49891

            Bug ID: 49891
           Summary: No hint to use -std=c++20 when using 'concept' or
                    'requires' with older -std modes
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

template<typename T>
  concept snackable = requires (sizeof(T) != 1)

template<typename T>
  struct S { };

template<typename T> requires snackable<T>
  struct S<T> { };


Compiling this C++20 code without -std=c++20 produces a load of parser errors:

c.C:2:3: error: unknown type name 'concept'
  concept snackable = requires (sizeof(T) != 1)
  ^
c.C:2:23: error: use of undeclared identifier 'requires'
  concept snackable = requires (sizeof(T) != 1)
                      ^
c.C:7:22: error: unknown type name 'requires'
template<typename T> requires snackable<T>
                     ^
c.C:7:31: error: variable template partial specialization does not specialize
any template argument; to define the primary template, remove the template
argument list
template<typename T> requires snackable<T>
                              ^        ~~~
c.C:7:43: error: expected ';' at end of declaration
template<typename T> requires snackable<T>
                                          ^
                                          ;
c.C:8:12: error: use of undeclared identifier 'T'
  struct S<T> { };
           ^
6 errors generated.

There's no hint that you need to enable C++20.

GCC does better:

c.C:2:3: error: 'concept' does not name a type
    2 |   concept snackable = requires (sizeof(T) != 1)
      |   ^~~~~~~
c.C:2:3: note: 'concept' only available with '-std=c++20' or '-fconcepts'
c.C:7:22: error: 'requires' does not name a type
    7 | template<typename T> requires snackable<T>
      |                      ^~~~~~~~
c.C:7:22: note: 'requires' only available with '-std=c++20' or '-fconcepts'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210408/d423255d/attachment.html>


More information about the llvm-bugs mailing list