[Bug c++/71138] New: [concepts] ill-formed non-constant expression use in nested requirement produces duplicated diagnostics with poor source locations
tom at honermann dot net
gcc-bugzilla@gcc.gnu.org
Mon May 16 03:35:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71138
Bug ID: 71138
Summary: [concepts] ill-formed non-constant expression use in
nested requirement produces duplicated diagnostics
with poor source locations
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tom at honermann dot net
CC: andrew.n.sutton at gmail dot com, asutton at gcc dot gnu.org
Target Milestone: ---
The following test case is ill-formed and gcc r236238 correctly rejects it.
However, duplicate diagnostic are issued and the diagnostics fail to identify
the problematic source code.
The test case contains two instances of constraint satisfaction failures
labeled #1 and #2. The first occurs in a static_assert and produces a single
error message. The second occurs in overload resolution and produces three
duplicate error messages.
None of the diagnostics produce identify the problematic source code annotated
in the test case.
$ cat t.cpp
template<typename T>
constexpr bool p(T) { return true; }
template<typename T>
concept bool C = requires(T t) {
requires p(t); // An error should be reported here.
};
static_assert(C<int>); // #1: error: ‘t’ is not a constant expression
template<C T>
int f(T) { return 1; }
auto x = f(1); // #2: (3x) error: ‘t’ is not a constant expression
$ svn info
Path: .
Working Copy Root Path: /home/tom/src/gcc-trunk
URL: svn://gcc.gnu.org/svn/gcc/trunk
Relative URL: ^/trunk
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 236239
Node Kind: directory
Schedule: normal
Last Changed Author: uros
Last Changed Rev: 236238
Last Changed Date: 2016-05-14 05:07:13 -0400 (Sat, 14 May 2016)
$ g++ --version
g++ (GCC) 7.0.0 20160514 (experimental)
...
$ g++ -c -std=c++1z -fconcepts t.cpp
t.cpp:8:15: error: ‘t’ is not a constant expression
static_assert(C<int>); // #1: error: ‘t’ is not a constant expression
^~~~~~
t.cpp:12:13: error: ‘t’ is not a constant expression
auto x = f(1); // #2: (3x) error: ‘t’ is not a constant expression
^
t.cpp:12:13: error: ‘t’ is not a constant expression
t.cpp:12:13: error: cannot call function ‘int f(T) [with T = int]’
t.cpp:11:5: note: constraints not satisfied
int f(T) { return 1; }
^
t.cpp:12:13: error: ‘t’ is not a constant expression
auto x = f(1); // #2: (3x) error: ‘t’ is not a constant expression
^
t.cpp:11:5: note: concept ‘C<int>’ was not satisfied
int f(T) { return 1; }
^
More information about the Gcc-bugs
mailing list