g++ incorrect error printed in gcc-2.95 & gcc-2.7.2

dek@cgl.ucsf.edu dek@cgl.ucsf.edu
Tue Jun 1 16:31:00 GMT 1999


The following "simple" program causes gcc-2.95 and older g++ to 
produce an incorrect error message:

extern "C" {
#include <errno.h>
}

int main(void)
{
    errno = 1;
    ::errno = 1;

}


There is no "(" in the file except the main() line,
yet g++ says 

g++ test.C
test.C: In function `int main()':
test.C:8: parse error before `('

Here is the detailed info:

dek@nano:~/EgcsBug
:g++ -v --save-temps test.C
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/specs
gcc version gcc-2.95 19990524 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GN
UC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__
linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i38
6 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ test.C test.ii
GNU CPP version gcc-2.95 19990524 (prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/../../../../include/g++-2
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/gcc-2.95/cc1plus test.ii -quiet -dumpbase test.cc -version
 -o test.s
GNU C++ version gcc-2.95 19990524 (prerelease) (i686-pc-linux-gnu) compiled by GNU C version gcc-2.9
5 19990524 (prerelease).
test.C: In function `int main()':
test.C:8: parse error before `('

-----------------------------------------------------------------------------
Email: dek@cgl.ucsf.edu   David Konerding   WWW: http://picasso.ucsf.edu/~dek
-----------------------------------------------------------------------------


More information about the Gcc-bugs mailing list