Bug 183386 - Non-POD data in switch outside block causes internal compiler error
Non-POD data in switch outside block causes internal compiler error
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3 (Show other bugs)
3.0
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-02-28 14:40 EST by David Resnick
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version: 3.2.3-54
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-03-15 12:22:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Resnick 2006-02-28 14:40:15 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

Description of problem:
Below is an example of something I hit in my code.  Not a big deal,
repair my bad code by putting the case with the declaration in a block.  
I see from the C++ standard that jumping (goto or switch) across a
non-POD declaration (or any declaration with an initializer) is
forbidden.  Just a bit surprised to see the compiler report an
internal error on it.  Note that if instead of a std::string it is a 
POD type declared in the case statement, the warning is still there 
about crossing initialization but not the internal compiler error.

temp(1552)$ g++ --version
g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34)

temp(1551)$ cat foo.cpp
#include <string>
int main(void)
{
  int i = 4;
  switch (i) {
  case 1:
    std::string bar="quux";
    break;
  default:
    break;
  }
  return 0;
}

temp(1550)$ g++ -Wall -o foo foo.cpp
foo.cpp: In function `int main()':
foo.cpp:11: jump to case label
foo.cpp:9:   crosses initialization of `std::string bar'

Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.

Version-Release number of selected component (if applicable):
gcc-3.2.3-34

How reproducible:
Always

Steps to Reproduce:
1. See Description above for C++ program and compiler args used
2.
3.
  

Actual Results:  I saw this:

Internal compiler error: Error reporting routines re-entered.

Expected Results:  Error message is fine.  Just surprised to see
an internal compiler error.

Additional info:
Comment 1 Jakub Jelinek 2006-03-15 12:22:52 EST
Can't reproduce with RHEL3 U7:
g++ -v; g++ -Wall -o 183386{,.C}; echo $?
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54)
183386.C: In function `int main()':
183386.C:9: jump to case label
183386.C:7:   crosses initialization of `std::string bar'
183386.C:9: warning: destructor needed for `std::string bar'
183386.C:9: warning: where case label appears here
183386.C:9: warning: (enclose actions of previous case statements requiring
   destructors in their own scope.)
1

Note You need to log in before you can comment on or make changes to this bug.