[gnu.g++.bug] g++ bugoid

purtill@BOURBAKI.MIT.EDU (06/15/89)

setup:
	machine: Sun 3/50
	OS: Sun UNIX 4.2 Release 3.5
	md -> config/m68k.md
	tm.h -> config/tm-sun2+.h
	g++ version 1.35.0

If you unshar the enclosed file (test.cc) and run g++ on it as shown:

% g++ -v -g -O -W -c test.cc -o test.o
g++ version 1.35.0
 /bb/purtill/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc680
00 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -Dmc68010 test
.cc /tmp/cca11803.cpp
GNU CPP version 1.35
 /bb/purtill/lib/gcc-cc1plus /tmp/cca11803.cpp -quiet -dumpbase test.cc -W -opt
-version -G -o /tmp/cca11803.s
GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35.
In function int main (int, char *):
test.cc:6: `vargc' was not declared (first use this function)
test.cc:6: (Each undeclared identifier is reported only once
test.cc:6: for each function it appears in.)
test.cc:6: `vargc' was not declared (first use this function)
test.cc:7: `vargc' was not declared (first use this function)
%
	Notice that the last two errors contradict the first, and
furthermore are wrong about vargc being first used there.  This isn't
actually a bug (since the input is incorrect) but it is very annoying!

^.-.^ Mark Purtill		purtill@math.mit.edu  (617)623-6238 - H
((")) Dept. of Math, MIT 2-229, Cambridge, MA  02139  (617)253-1589 - O

-------------------->8-cut-here-8<--------------------
#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  test.cc
#
sed 's/^X//' << 'SHAR_EOF' > test.cc &&
X// This exhibits a bugoid in g++.
X
Xmain( int argc, char *argv)
X{
X    if( vargc > 0) for( int i=0; i<vargc; ++i) argv[i]++ ;
X    return vargc ;
X    }
X    
X#if 0
X// output:
X// g++ -v -g -O -W -c test.cc -o test.o
Xg++ version 1.35.0
X /bb/purtill/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc680
X00 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -Dmc68010 test
X.cc /tmp/cca11803.cpp
XGNU CPP version 1.35
X /bb/purtill/lib/gcc-cc1plus /tmp/cca11803.cpp -quiet -dumpbase test.cc -W -opt
X-version -G -o /tmp/cca11803.s
XGNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35.
XIn function int main (int, char *):
Xtest.cc:6: `vargc' was not declared (first use this function)
Xtest.cc:6: (Each undeclared identifier is reported only once
Xtest.cc:6: for each function it appears in.)
Xtest.cc:6: `vargc' was not declared (first use this function)
Xtest.cc:7: `vargc' was not declared (first use this function)
X
X// Notice that the last two errors contradict the first, and furthermore
X// are wrong about vargc being first used there.
X#endif
SHAR_EOF
chmod 0644 test.cc || echo "restore of test.cc fails"
exit 0