[LLVMbugs] [Bug 7789] New: Failure to detect "jump to case label crosses initialization"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 2 05:49:07 PDT 2010


           Summary: Failure to detect "jump to case label crosses
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: bugzilla-clang at sogetthis.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Created an attachment (id=5308)
 --> (http://llvm.org/bugs/attachment.cgi?id=5308)
source code to reproduce bug


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
and the explanation for it's behavior, g++ is correct.

switch (a) {
  case 1:
  int a = 1;
  case 2:

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

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