<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - No hint to use -std=c++20 when using 'concept' or 'requires' with older -std modes"
href="https://bugs.llvm.org/show_bug.cgi?id=49891">49891</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>No hint to use -std=c++20 when using 'concept' or 'requires' with older -std modes
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zilla@kayari.org
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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'</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>