https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120017
Bug ID: 120017 Summary: Nested diagnostics could be slightly improved for concepts-related diagnostics Product: gcc Version: unknown Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ensadc at mailnesia dot com CC: dmalcolm at gcc dot gnu.org Target Milestone: --- This issue is specific to the new `experimental-nesting` option (`-fdiagnostics-set-output=text:experimental-nesting=yes`). ==== https://godbolt.org/z/Wc1fqzoan ==== template<class T> struct A {}; template<class T> using B = A<T>::B; template<class T> concept C = false; template<class T> concept D = requires(T t) { typename B<T>; requires C<T>; }; static_assert(D<int>); ==== <source>:16:15: error: static assertion failed <source>:16:15: note: constraints not satisfied • (level 1):required by the constraints of 'template<class T> concept D' • (level 1):in requirements with 'T t' [with T = int] • (level 1):the required type 'B<T>' is invalid, because • (level 1):In substitution of 'template<class T> using B = typename A::B [with T = int]': • (level 1):required from here • (level 1):error: no type named 'B' in 'struct A<int>' • (level 1):nested requirement 'C<T>' is not satisfied, because • (level 1):required for the satisfaction of 'C<T>' [with T = int] • (level 1):the expression 'false' evaluated to 'false' ==== I'm using `experimental-nesting-show-locations=no`, `experimental-nesting-show-levels=yes` and `-fno-diagnostics-show-caret` to make it clearer to see the issue, and `-fconcepts-diagnostics-depth=3` to make GCC not truncate the concepts-related diagnostics. So the full command-line is: g++ -std=c++20 -fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no,experimental-nesting-show-levels=yes -fno-diagnostics-show-caret -fconcepts-diagnostics-depth=3 example.cpp I expect the messages after "because" to be more nested than the ones that end with "because". That is, I expect the nesting levels to be: ``` <source>:16:15: error: static assertion failed <source>:16:15: note: constraints not satisfied • (level 1):required by the constraints of 'template<class T> concept D' • (level 1):in requirements with 'T t' [with T = int] • (level 1):the required type 'B<T>' is invalid, because • (level 2):In substitution of 'template<class T> using B = typename A::B [with T = int]': • (level 2):required from here • (level 2):error: no type named 'B' in 'struct A<int>' • (level 1):nested requirement 'C<T>' is not satisfied, because • (level 2):required for the satisfaction of 'C<T>' [with T = int] • (level 2):the expression 'false' evaluated to 'false' ``` By the way, the nested messages are already a huge improvement to the old, flat structure. I really appreciate it.