public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics
@ 2022-04-19  6:58 ich.freak at gmx dot net
  2022-04-19  9:57 ` [Bug c++/105307] " marxin at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ich.freak at gmx dot net @ 2022-04-19  6:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105307

            Bug ID: 105307
           Summary: -fmax-errors truncated for concept diagnostics
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ich.freak at gmx dot net
  Target Milestone: ---

In #92440 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92440) it was remarked
that -fmax-errors=1 truncates the first error "in the middle of the sentence"
and a patch was supplied. However, the problem still persists for concepts:


template<class T> concept HasX = requires { T::x; };
template <HasX T> struct S {};
struct NoX {};
S<NoX> s;

compiled with
> g++ -std=c++20 -fconcepts-diagnostics-depth=3 test.cpp -o test
yields:

>test.cpp:4:6: error: template constraint failure for 'template<class T>  >requires  HasX<T> struct S'
>    4 | S<NoX> s;
>      |      ^
>test.cpp:4:6: note: constraints not satisfied
>test.cpp: In substitution of 'template<class T>  requires  HasX<T> struct S >[with T = NoX]':
>test.cpp:4:6:   required from here
>test.cpp:1:26:   required for the satisfaction of 'HasX<T>' [with T = NoX]
>test.cpp:1:33:   in requirements  [with T = NoX]
>test.cpp:1:47: note: the required expression 'T::x' is invalid, because
>    1 | template<class T>concept HasX = requires { T::x; };
>      |                                               ^
>test.cpp:1:47: error: 'x' is not a member of 'NoX'

And, if we add -fmax-errors=1, we get:

>test.cpp:4:6: error: template constraint failure for 'template<class T>  >requires  HasX<T> struct S'
>    4 | S<NoX> s;
>      |      ^
>test.cpp:4:6: note: constraints not satisfied
>test.cpp: In substitution of 'template<class T>  requires  HasX<T> struct S >[with T = NoX]':
>test.cpp:4:6:   required from here
>test.cpp:1:26:   required for the satisfaction of 'HasX<T>' [with T = NoX]
>test.cpp:1:33:   in requirements  [with T = NoX]
>test.cpp:1:47: note: the required expression 'T::x' is invalid, because
>    1 | template<class T>concept HasX = requires { T::x; };
>      |                                               ^
>compilation terminated due to -fmax-errors=1.

However, the "explanatory errors" that are getting truncated here still
logically belong to the same error and should, therefore, not be truncated.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/105307] -fmax-errors truncated for concept diagnostics
  2022-04-19  6:58 [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics ich.freak at gmx dot net
@ 2022-04-19  9:57 ` marxin at gcc dot gnu.org
  2022-04-19 14:20 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-19  9:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105307

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-04-19
             Status|UNCONFIRMED                 |ASSIGNED
                 CC|                            |marxin at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Let me take a llok.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/105307] -fmax-errors truncated for concept diagnostics
  2022-04-19  6:58 [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics ich.freak at gmx dot net
  2022-04-19  9:57 ` [Bug c++/105307] " marxin at gcc dot gnu.org
@ 2022-04-19 14:20 ` marxin at gcc dot gnu.org
  2022-04-20  8:35 ` ich.freak at gmx dot net
  2022-04-20  8:42 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-19 14:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105307

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|marxin at gcc dot gnu.org          |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
So the 2 errors are printed with the following backtraces:

#0  error (gmsgid=gmsgid@entry=0x22ca610 "template constraint failure for %qD")
at /home/marxin/Programming/gcc/gcc/diagnostic.cc:1837
#1  0x0000000000bf3177 in lookup_template_class_1 (complain=3,
entering_scope=<optimized out>, context=<optimized out>, in_decl=0x0,
arglist=0x7ffff7752ba0, d1=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/pt.cc:10013
#2  lookup_template_class (d1=d1@entry=0x7ffff7fb3100,
arglist=arglist@entry=0x7ffff7752b80, in_decl=in_decl@entry=0x0,
context=context@entry=0x0, entering_scope=entering_scope@entry=0,
complain=complain@entry=35) at /home/marxin/Programming/gcc/gcc/cp/pt.cc:10350
#3  0x0000000000c1de16 in finish_template_type (name=name@entry=0x7ffff7fb3100,
args=args@entry=0x7ffff7752b80, entering_scope=0) at
/home/marxin/Programming/gcc/gcc/cp/semantics.cc:3710
#4  0x0000000000b81462 in cp_parser_template_id (parser=0x7ffff7639850,
template_keyword_p=<optimized out>, check_dependency_p=<optimized out>,
tag_type=<optimized out>, is_declaration=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:18332
#5  0x0000000000b81716 in cp_parser_class_name (parser=0x7ffff7639850,
typename_keyword_p=<optimized out>, template_keyword_p=<optimized out>,
tag_type=none_type, check_dependency_p=<optimized out>, class_head_p=<optimized
out>, is_declaration=false, enum_ok=true) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:25711
#6  0x0000000000b77ee8 in cp_parser_qualifying_entity (is_declaration=false,
type_p=false, check_dependency_p=true, template_keyword_p=false,
typename_keyword_p=false, parser=0x7ffff7639850) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:7116
#7  cp_parser_nested_name_specifier_opt (parser=<optimized out>,
typename_keyword_p=<optimized out>, check_dependency_p=<optimized out>,
type_p=<optimized out>, is_declaration=<optimized out>,
template_keyword_p=false) at /home/marxin/Programming/gcc/gcc/cp/parser.cc:6798
#8  0x0000000000b9dc0f in cp_parser_template_introduction
(parser=0x7ffff7639850, member_p=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:31443
#9  0x0000000000ba0637 in cp_parser_declaration (parser=0x7ffff7639850,
prefix_attrs=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:14960
#10 0x0000000000ba116c in cp_parser_toplevel_declaration
(parser=0x7ffff7639850) at /home/marxin/Programming/gcc/gcc/cp/parser.cc:14987
#11 cp_parser_translation_unit (parser=0x7ffff7639850) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:5010
#12 c_parse_file () at /home/marxin/Programming/gcc/gcc/cp/parser.cc:48067
#13 0x0000000000ce579a in c_common_parse_file () at
/home/marxin/Programming/gcc/gcc/c-family/c-opts.cc:1240
#14 0x0000000001260424 in compile_file () at
/home/marxin/Programming/gcc/gcc/toplev.cc:452
#15 0x00000000009cfdf1 in do_compile (no_backend=false) at
/home/marxin/Programming/gcc/gcc/toplev.cc:2168
#16 toplev::main (this=this@entry=0x7fffffffd88e, argc=<optimized out>,
argc@entry=16, argv=<optimized out>, argv@entry=0x7fffffffd9b8) at
/home/marxin/Programming/gcc/gcc/toplev.cc:2320
#17 0x00000000009d1d65 in main (argc=16, argv=0x7fffffffd9b8) at
/home/marxin/Programming/gcc/gcc/main.cc:39

#0  error_at (loc=260416, gmsgid=0x22aa635 "%qD is not a member of %qT") at
/home/marxin/Programming/gcc/gcc/diagnostic.cc:1864
#1  0x0000000000bc632d in tsubst_qualified_id (qualified_id=0x7ffff776e000,
args=<optimized out>, complain=<optimized out>, in_decl=<optimized out>,
done=<optimized out>, address_p=<optimized out>) at
/home/marxin/Programming/gcc/gcc/tree.h:3958
#2  0x0000000000bc7a89 in tsubst_copy_and_build (t=0x7ffff776e000,
args=0x7ffff7752d00, complain=3, in_decl=0x0, function_p=<optimized out>,
integral_constant_expression_p=false) at
/home/marxin/Programming/gcc/gcc/cp/pt.cc:20352
#3  0x0000000000bda73f in tsubst_expr (integral_constant_expression_p=false,
in_decl=0x0, complain=3, args=0x7ffff7752d00, t=0x7ffff776e000) at
/home/marxin/Programming/gcc/gcc/cp/pt.cc:19482
#4  tsubst_expr (t=t@entry=0x7ffff776e000, args=args@entry=0x7ffff7752d00,
complain=complain@entry=3, in_decl=in_decl@entry=0x0,
integral_constant_expression_p=integral_constant_expression_p@entry=false) at
/home/marxin/Programming/gcc/gcc/cp/pt.cc:18441
#5  0x0000000000a3695c in tsubst_valid_expression_requirement
(t=0x7ffff776e000, args=args@entry=0x7ffff7752d00, info=..., info=...) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:1935
#6  0x0000000000a39a37 in tsubst_simple_requirement (info=..., info=...,
args=0x7ffff7752d00, t=0x7ffff77529c0) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:1958
#7  tsubst_requirement (info=..., args=0x7ffff7752d00, t=0x7ffff77529c0) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:2155
#8  tsubst_requires_expr (t=<optimized out>, args=<optimized out>, info=...) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:2282
#9  0x0000000000a3a327 in diagnose_atomic_constraint (t=0x7ffff7752cc0,
args=0x7ffff7752d00, result=0x7ffff762c2a0, info=...) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3738
#10 0x0000000000a3b774 in satisfy_atom (info=..., args=0x7ffff7752d00,
t=0x7ffff7752cc0) at /home/marxin/Programming/gcc/gcc/cp/constraint.cc:2994
#11 satisfy_constraint_r (t=<optimized out>, args=<optimized out>, info=...) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3023
#12 0x0000000000a3b983 in satisfy_normalized_constraints
(t=t@entry=0x7ffff7752ca0, args=args@entry=0x7ffff7752ba0, info=...) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3048
#13 0x0000000000a388cb in satisfy_declaration_constraints (info=...,
args=0x7ffff7752ba0, t=0x7ffff7fb3100) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3259
#14 constraint_satisfaction_value (t=0x7ffff7fb3100, args=0x7ffff7752ba0,
info=...) at /home/marxin/Programming/gcc/gcc/cp/constraint.cc:3280
#15 0x0000000000a3bb30 in diagnose_constraints (loc=<optimized out>,
t=t@entry=0x7ffff7fb3100, args=args@entry=0x7ffff7752ba0) at
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3803
#16 0x0000000000bf318d in lookup_template_class_1 (complain=3,
entering_scope=<optimized out>, context=<optimized out>, in_decl=0x0,
arglist=0x7ffff7752ba0, d1=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/pt.cc:10014
#17 lookup_template_class (d1=d1@entry=0x7ffff7fb3100,
arglist=arglist@entry=0x7ffff7752b80, in_decl=in_decl@entry=0x0,
context=context@entry=0x0, entering_scope=entering_scope@entry=0,
complain=complain@entry=35) at /home/marxin/Programming/gcc/gcc/cp/pt.cc:10350
#18 0x0000000000c1de16 in finish_template_type (name=name@entry=0x7ffff7fb3100,
args=args@entry=0x7ffff7752b80, entering_scope=0) at
/home/marxin/Programming/gcc/gcc/cp/semantics.cc:3710
#19 0x0000000000b81462 in cp_parser_template_id (parser=0x7ffff7639850,
template_keyword_p=<optimized out>, check_dependency_p=<optimized out>,
tag_type=<optimized out>, is_declaration=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:18332
#20 0x0000000000b81716 in cp_parser_class_name (parser=0x7ffff7639850,
typename_keyword_p=<optimized out>, template_keyword_p=<optimized out>,
tag_type=none_type, check_dependency_p=<optimized out>, class_head_p=<optimized
out>, is_declaration=false, enum_ok=true) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:25711
#21 0x0000000000b77ee8 in cp_parser_qualifying_entity (is_declaration=false,
type_p=false, check_dependency_p=true, template_keyword_p=false,
typename_keyword_p=false, parser=0x7ffff7639850) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:7116
#22 cp_parser_nested_name_specifier_opt (parser=<optimized out>,
typename_keyword_p=<optimized out>, check_dependency_p=<optimized out>,
type_p=<optimized out>, is_declaration=<optimized out>,
template_keyword_p=false) at /home/marxin/Programming/gcc/gcc/cp/parser.cc:6798
#23 0x0000000000b9dc0f in cp_parser_template_introduction
(parser=0x7ffff7639850, member_p=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:31443
#24 0x0000000000ba0637 in cp_parser_declaration (parser=0x7ffff7639850,
prefix_attrs=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:14960
#25 0x0000000000ba116c in cp_parser_toplevel_declaration
(parser=0x7ffff7639850) at /home/marxin/Programming/gcc/gcc/cp/parser.cc:14987
#26 cp_parser_translation_unit (parser=0x7ffff7639850) at
/home/marxin/Programming/gcc/gcc/cp/parser.cc:5010
#27 c_parse_file () at /home/marxin/Programming/gcc/gcc/cp/parser.cc:48067
#28 0x0000000000ce579a in c_common_parse_file () at
/home/marxin/Programming/gcc/gcc/c-family/c-opts.cc:1240
#29 0x0000000001260424 in compile_file () at
/home/marxin/Programming/gcc/gcc/toplev.cc:452
#30 0x00000000009cfdf1 in do_compile (no_backend=false) at
/home/marxin/Programming/gcc/gcc/toplev.cc:2168
#31 toplev::main (this=this@entry=0x7fffffffd88e, argc=<optimized out>,
argc@entry=16, argv=<optimized out>, argv@entry=0x7fffffffd9b8) at
/home/marxin/Programming/gcc/gcc/toplev.cc:2320
#32 0x00000000009d1d65 in main (argc=16, argv=0x7fffffffd9b8) at
/home/marxin/Programming/gcc/gcc/main.cc:39

So each of them emitted quite far from each other, I don't have an easy fix.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/105307] -fmax-errors truncated for concept diagnostics
  2022-04-19  6:58 [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics ich.freak at gmx dot net
  2022-04-19  9:57 ` [Bug c++/105307] " marxin at gcc dot gnu.org
  2022-04-19 14:20 ` marxin at gcc dot gnu.org
@ 2022-04-20  8:35 ` ich.freak at gmx dot net
  2022-04-20  8:42 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ich.freak at gmx dot net @ 2022-04-20  8:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105307

--- Comment #3 from Igel <ich.freak at gmx dot net> ---
well, quite surely,
> error: 'x' is not a member of 'NoX'
is not the only instance of this problem.

It seems to me that gcc is not differentiating "normal errors" from
"explanatory errors", and I guess introducing this difference would actually be
somewhat of a larger refactorization. I'm just speculating tho here...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/105307] -fmax-errors truncated for concept diagnostics
  2022-04-19  6:58 [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics ich.freak at gmx dot net
                   ` (2 preceding siblings ...)
  2022-04-20  8:35 ` ich.freak at gmx dot net
@ 2022-04-20  8:42 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-20  8:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105307

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Igel from comment #3)
> well, quite surely,
> > error: 'x' is not a member of 'NoX'
> is not the only instance of this problem.
> 
> It seems to me that gcc is not differentiating "normal errors" from
> "explanatory errors", and I guess introducing this difference would actually
> be somewhat of a larger refactorization. I'm just speculating tho here...

The issue is that the diagnostics are not tied together and we stop compilation
at the Nth 'error' without knowing that explaining diagnostic parts follow.

To fix that indeed requires major refactoring as for example to first somehow
compose the group of diagnostics and separate actual emission (and then
compilation termination) from that.

A simpler piecemail approach might be to introduce error_start{,_at} and
error_end where error_end would then trigger the exiting.  In other areas
of the compiler there might already be infrastructure to group diagnostics,
maybe something can be re-used or generalized there.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-20  8:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19  6:58 [Bug c++/105307] New: -fmax-errors truncated for concept diagnostics ich.freak at gmx dot net
2022-04-19  9:57 ` [Bug c++/105307] " marxin at gcc dot gnu.org
2022-04-19 14:20 ` marxin at gcc dot gnu.org
2022-04-20  8:35 ` ich.freak at gmx dot net
2022-04-20  8:42 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).