This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Analysis of PR c++/2015
- To: gccbugs <gcc-bugs at gcc dot gnu dot org>
- Subject: Analysis of PR c++/2015
- From: Roberto Bagnara <bagnara at cs dot unipr dot it>
- Date: Tue, 24 Jul 2001 10:21:13 +0200
- CC: nathan at gcc dot gnu dot org
- Organization: Department of Mathematics, University of Parma, Italy
- References: <20010427143255.514.qmail@sourceware.cygnus.com>
nathan@gcc.gnu.org wrote:
>
> Synopsis: New ICE in snapshot of February 17
>
> State-Changed-From-To: open->analyzed
> State-Changed-By: nathan
> State-Changed-When: Fri Apr 27 10:32:55 2001
> State-Changed-Why:
> confirmed as a bug
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2015&database=gcc
I think the following analysis and the much simplified testcase
should help fixing PR #2015 in GNATS.
Consider the following snippet:
//--------------------------------//
static int i = 10;
// namespace N {
int* p = new int[i];
// };
void foo() {
}
//--------------------------------//
This causes GCC 3.0 to behave as follows
$ /usr/local/beta/bin/g++ gccbug.cc
gccbug.cc:6: variable-size type declared outside of any function
gccbug.cc:6: variable-size type declared outside of any function
which is fine, apart from the useless repetition.
If we uncomment the namespace enclosure the the variable-size array,
we obtain an ICE.
//--------------------------------//
static int i = 10;
namespace N {
int* p = new int[i];
};
void foo() {
}
//--------------------------------//
$ /usr/local/beta/bin/g++ gccbug.cc
gccbug.cc: In function `void __static_initialization_and_destruction_0(int,
int)':
gccbug.cc:5: Internal compiler error in find_function_data, at function.c:328
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
The problem seems to be that some part of the compiler treats
what follows "namespace N" as a function body, and this prevents
the recognition of the erroneous situation.
When later find_function_data() is invoked the compiler realizes that
there is no containing function and reacts to this by calling abort().
Here is some more info about the compiler used and the machine:
$ /usr/local/beta/bin/g++ -v
Reading specs from /usr/local/beta/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc-3.0/configure --prefix=/usr/local/beta
Thread model: single
gcc version 3.0
$ uname -a
Linux zoltan.unisuv.it 2.4.6 #16 Fri Jul 6 18:25:36 CEST 2001 i686 unknown
All the best,
Roberto Bagnara
--
Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it