[Bug c++/39028] New: C++ front-end rejects __label__ at the beginning of a block after for and while

2009-01-29 Thread springl-gcc at bfw-online dot de
Trying to compile the c++ program label.C

void c ()
{ for (;;)   {__label__ l; goto l; l:;}
  while (1)  {__label__ l; goto l; l:;}
  if (1) {__label__ l; goto l; l:;}
  do {__label__ l; goto l; l:;} while (1);
 {__label__ l; goto l; l:;}
}

using
  g++ -Wall -Wextra   -c label.C
with g++ versions 4.4.0 20090129 (experimental) and 4.3.3 gives:

label.C: In function 'void c()':
label.C:2: error: '__label__' not at the beginning of a block
label.C:3: error: '__label__' not at the beginning of a block
label.C:3: error: duplicate label 'l'

The fix for bug 32121 C++ front-end accepts invalid __label__
declarations (svn revision 129253) moved handling __label__ declarations
to function cp_parser_compound_statement in gcc/cp/parser.c and omitted
it in function cp_parser_already_scoped_statement.  The newly introduced
tests cases only check the error case for while and for statements,
unfortunately.

Without any deeper understanding of gcc internals, I suggest two
possible fixes:

- copy the two lines handling __label__ declarations
from function cp_parser_compound_statement to function
cp_parser_already_scoped_statement, which might be the smallest change or
- merge part of cp_parser_already_scoped_statement's functionality to
cp_parser_compound_statement avoiding code duplication.


-- 
   Summary: C++ front-end rejects __label__ at the beginning of a
block after for and while
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: springl-gcc at bfw-online dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39028



[Bug c++/37146] New: ICE - Compiler segfaults

2008-08-18 Thread springl-gcc at bfw-online dot de
g++ from snapshot gcc-4.4-20080815.tar.bz2 gives

v.cc: In member function 'kostenbezug_e
verteilung_c::bezug_ausrechnen(kostenbezug_e) const':
v.cc:12: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.

on this program:
-
enum kostenbezug_e
{ kostenbezug_keiner = 0,
  kostenbezug_einheitlich = 'E',
};

struct verteilung_c
{ kostenbezug_e bezug: 8;
  enum kostenbezug_e bezug_ausrechnen (kostenbezug_e) const;
};

kostenbezug_e
verteilung_c::bezug_ausrechnen (kostenbezug_e b) const
{ return bezug  bezug != kostenbezug_einheitlich? bezug: b;
}
-
when called as
  g++ -O2 -c -o v.o v.cc

This is running on Linux version 2.6.26.2, glibc 2.6.1.
gcc was configured using:
  configure --prefix=/scratch/gcc/4.4-2008-08-08 --enable-shared \
--enable-languages=all --with-sysroot=/usr/i686-pc-linux-gnulibc2


-- 
   Summary: ICE - Compiler segfaults
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: springl-gcc at bfw-online dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37146