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

            Bug ID: 120343
           Summary: inconvenient order of error messages
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f.heckenb...@fh-soft.de
  Target Milestone: ---

% cat test.cpp
struct a
{
  int f () { return a + b + c; }
  int g () { return { ]; }
  int a, b, c;
};
% g++ -Wall -Werror -Wextra-semi test.cpp
test.cpp:6:2: error: extra ';' after in-class function definition
[-Werror=extra-semi]
    6 | };
      |  ^
      |  -
test.cpp:6:3: error: expected '}' at end of input
    6 | };
      |   ^
test.cpp:2:1: note: to match this '{'
    2 | {
      | ^
test.cpp: In member function 'int a::f()':
test.cpp:3:23: error: expected primary-expression before '+' token
    3 |   int f () { return a + b + c; }
      |                       ^
test.cpp:3:25: error: 'b' was not declared in this scope
    3 |   int f () { return a + b + c; }
      |                         ^
test.cpp:3:29: error: 'c' was not declared in this scope
    3 |   int f () { return a + b + c; }
      |                             ^
test.cpp: In member function 'int a::g()':
test.cpp:4:23: error: expected primary-expression before ']' token
    4 |   int g () { return { ]; }
      |                       ^
test.cpp:4:23: error: expected '}' before ']' token
test.cpp:4:21: note: to match this '{'
    4 |   int g () { return { ]; }
      |                     ^
test.cpp:4:23: error: cannot convert '<brace-enclosed initializer list>' to
'int' in return
    4 |   int g () { return { ]; }
      |                       ^
test.cpp:4:23: error: expected ';' before ']' token
test.cpp:4:23: error: expected primary-expression before ']' token
test.cpp: At global scope:
test.cpp:6:3: error: expected unqualified-id at end of input
    6 | };
      |   ^
cc1plus: all warnings being treated as errors

The error in the program is a simple typo (']' instead of '}'), but gcc only
tells me this after a lot of other errors resulting from the incorrect parse of
the following text -- here exemplified by the a, b, c stuff; in my actual code
this was pages of error messages which made it hard to find the actually
relevant ones (expected ... before ']').

Reply via email to