🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #232

Undeclared variables inside an array index call to "new"

#232
From: Kevin Burton
Date: Fri, 10 Apr 1992 19:34
46 lines
2064 bytes
OS: SunOS 4.0
Compiler: gcc/g++ 2.1 (using GNU ld 1.9, GNU as, 1.38)
Machine: Sun3/260

This bug has been reported already for gcc-1.40 but it still exists
for 2.1 so I am re-posting it.

Undeclared variables inside an array index in a call to "new" can generate
internal compiler errors.  The following code

struct foo
{
    int a;
    foo() : a(0) {}
};

struct bar
{
    foo * x,y;
    bar() 
    {
	x = new foo[(n+1)*(m+1)];
	y = new foo[(n+1)*(m+1)];
    }
};

Gives the following output:

burton@inno$ gcc -v -c bug2.cc
Reading specs from /usr/local/lib/gcc-lib/sun3os4/2.1/specs
gcc version 2.1
 /usr/local/lib/gcc-lib/sun3os4/2.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__mc68000 -D__sun -D__unix -D__HAVE_68881__ -D__mc68020__ -Dmc68020 bug2.cc /usr/tmp/cca07263.i
GNU CPP version 2.1 (68k, MIT syntax)
 /usr/local/lib/gcc-lib/sun3os4/2.1/cc1plus /usr/tmp/cca07263.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca07263.s
GNU C++ version 2.1 (68k, MIT syntax) compiled by GNU C version 2.1.
bug2.cc: In method `bar::bar ()':
bug2.cc:13: `n' undeclared (first use this function)
bug2.cc:13: (Each undeclared identifier is reported only once
bug2.cc:13: for each function it appears in.)
bug2.cc:13: `m' undeclared (first use this function)
gcc: Internal compiler error: program cc1plus got fatal signal 11

--
Kevin Burton                                mail: burton@inno.heurikon.com
Innovision Corporation                      uucp: heurikon!inno!burton
8000 Excelsior Drive Suite #304, Madison WI 53717 at&t: 608/831-4441
Technical Details
Message-ID: <9204101934.AA07266@inno>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!heurikon.UUCP!burton

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!heurikon.UUCP!burton
From: burton@heurikon.UUCP (Kevin Burton)
Subject: Undeclared variables inside an array index call to "new"
Message-ID: <9204101934.AA07266@inno>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 10 Apr 1992 19:34:45 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 47