[LLVMbugs] [Bug 6502] New: Clang complains about indirect goto jumping over initializations where GCC doesn't
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Mar 4 17:25:58 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=6502
Summary: Clang complains about indirect goto jumping over
initializations where GCC doesn't
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P5
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: chandlerc at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
I know this code is terrifying, but some code generators produce this type of
pattern. The rationale for the combined switch and manually built indirect goto
table is to turn the goto-based solution off on compilers which don't support
it, and on for those that do. I haven't tried to reduce it by de-interleaving
them, not sure if that's relevant or not. It might be possible to reduce this
further, but this makes it an "interesting" test case without being enormous.
% cat t.cc
bool f(const unsigned* indices) {
static void* const dispatch_table[] = {
&&L1,
&&LEND,
};
for (const unsigned* next = indices; ; ) {
goto *dispatch_table[*next];
switch (*(next)) {
L1:
case 0: {
const int foo = 1.0;
(void)foo;
goto *dispatch_table[*(++next)];
break;
}
LEND:
case 1:
return true;
}
}
}
% ./bin/clang -fsyntax-only t.cc
t.cc:13:9: error: illegal indirect goto in protected scope, unknown effect on
scopes
goto *dispatch_table[*(++next)];
^
t.cc:11:19: note: jump bypasses variable initialization
const int foo = 1.0;
^
t.cc:6:24: note: jump bypasses variable initialization
for (const unsigned* next = indices; ; ) {
^
t.cc:7:5: error: illegal indirect goto in protected scope, unknown effect on
scopes
goto *dispatch_table[*next];
^
t.cc:6:24: note: jump bypasses variable initialization
for (const unsigned* next = indices; ; ) {
^
t.cc:4:5: error: address taken of label in protected scope, jump to it would
have unknown effect on scope
&&LEND,
^
t.cc:6:24: note: jump bypasses variable initialization
for (const unsigned* next = indices; ; ) {
^
t.cc:3:5: error: address taken of label in protected scope, jump to it would
have unknown effect on scope
&&L1,
^
t.cc:6:24: note: jump bypasses variable initialization
for (const unsigned* next = indices; ; ) {
^
9 diagnostics generated.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list