This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77846] New: Wrong error recovery with switch, goto and initialization skipped
- From: "denis.campredon at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Oct 2016 17:59:36 +0000
- Subject: [Bug c++/77846] New: Wrong error recovery with switch, goto and initialization skipped
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77846
Bug ID: 77846
Summary: Wrong error recovery with switch, goto and
initialization skipped
Product: gcc
Version: 6.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: denis.campredon at gmail dot com
Target Milestone: ---
Compiling the following code with -Wswitch
-------------------
enum E {A, B};
class C {public: C();};
void f(E e) {
goto out;
switch (e) {
case A:
C c;
case B:;
}
out:{}
}
-------------------
main.cpp: In function 'void f(E)':
main.cpp:9:14: error: jump to case label [-fpermissive]
case B:;
^
main.cpp:8:11: note: crosses initialization of 'C c'
C c;
^
main.cpp:6:12: warning: enumeration value 'B' not handled in switch [-Wswitch]
switch (e) {
^
----------------
The warning
main.cpp:6:12: warning: enumeration value 'B' not handled in switch [-Wswitch]
Is wrong since B is handled in the switch.
Also it would be nice if the line of the goto and the line of the label were
shown in the output, something like:
Jumping from `goto' to `label' crosses the initialization of 'c, d, ...