Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to detect "jump to case label crosses initialization" #8161

Closed
llvmbot opened this issue Aug 2, 2010 · 1 comment
Closed

Failure to detect "jump to case label crosses initialization" #8161

llvmbot opened this issue Aug 2, 2010 · 1 comment
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 2, 2010

Bugzilla Link 7789
Resolution FIXED
Resolved on Aug 02, 2010 18:33
Version trunk
OS Linux
Attachments source code to reproduce bug
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@rjmccall

Extended Description

Hi!

When compiling a 'switch' in which a 'case' contains an initialized variable (see example) Clang does so without complaining. g++ on the other hand produces an error "jump to case label crosses initialization".

I'm not really sure which is correct. According to this thread (http://www.velocityreviews.com/forums/t282021-error-jump-to-case-label.html) and the explanation for it's behavior, g++ is correct.

[code]
switch (a) {
//...
case 1:
int a = 1;
break;
case 2:
//...
}
[/code]

g++ output for attached file:

clang-bug.cpp: In function ‘int main()’:
clang-bug.cpp:10: error: jump to case label
clang-bug.cpp:7: error: crosses initialization of ‘int a’

clang++ output for attached file:

(compiles without error/warning)

My system:
Linux VirtUbuntu 2.6.32-24-generic #​38-Ubuntu SMP Mon Jul 5 09:22:14 UTC 2010 i686 GNU/Linux

clang version 2.8 (trunk 109579)
Target: i386-pc-linux-gnu
Thread model: posix

@rjmccall
Copy link
Contributor

rjmccall commented Aug 3, 2010

Fixed in r110082.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

2 participants