From: pasieka%sureal@cs.umass.edu
Subject: GCC 2.3.1 bug
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 11 Dec 1992 17:45:24 GMT

Version of GCC: 2.3.1
Machine Type: DECstation 5000

The following C program is pre-processed differently from GCC 2.2.2 and GCC 2.3.1:

/* Start ---------------------------------------------------------------- */

#ifdef NOTDEFINED
#undef NOTDEFINED
#endif

#define BODY_MACRO(BODY)    \
do { BODY; } while (0)

main ()
{

  BODY_MACRO(
	     {
	       printf ("Hello world 1!\n");
#ifdef NOTDEFINED
	       /* Just a comment */
#endif
	       printf ("Hello world 2!\n");
	     });

  return 0;
}

/* End ------------------------------------------------------------------ */

****** From GCC 2.2.2:

Command line:

gcc ../../../test/bugs/macro.c -v -save-temps -o macro

GCC Output:

Reading specs from /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/specs
gcc version 2.2.2
 /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/cpp -lang-c -v -undef
-D__GNUC__=2 -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD
-D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix
-D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__
-D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__
-D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD
-D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix
-D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C ../../../test/bugs/macro.c macro.i
GNU CPP version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/cc1 macro.i -quiet
-dumpbase macro.c -version -o macro.s
GNU C version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled
by GNU C version 2.2.2.
 as -nocpp -EL -v -o macro.o macro.s
/usr/lib/cmplrs/cc/as0 -v -G 8 -EL -g0 -O1 macro.s -o /tmp/ctmaa20006
-t /tmp/ctmsta20006 
as0: main 
0.0u 0.0s 0:00 16% 64+51k 3+10io 20pf+0w
/usr/lib/cmplrs/cc/as1 -v -G 8 -p0 -EL -g0 -O1 /tmp/ctmaa20006 -o
macro.o -t /tmp/ctmsta20006 
as1: main 
0.0u 0.0s 0:00 10% 105+72k 3+3io 36pf+0w
 /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/mips-tfile -v -I
macro.o~ -o macro.o macro.s
mips-tfile version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/ld -EL -o macro
/usr/lib/cmplrs/cc/crt0.o
-L/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2 -L/usr/lib/cmplrs/cc
-L/usr/lib/cmplrs/cc -L/usr/local/lib macro.o -lgcc -lc -lgcc

CPP output:

/* Start ---------------------------------------------------------------- */
# 1 "../../../test/bugs/macro.c"








main ()
{

  do { 
	     {
	       printf ("Hello world 1!\n");

	       printf ("Hello world 2!\n");
	     }; } while (0) ;



  return 0;
}
/* End ------------------------------------------------------------------ */

****** From GCC 2.3.1:

Command line:

/exp/rcf/share/bin/gcc macro.c -v -save-temps -o macro

GCC Output:

Reading specs from /exp/rcf/share/lib/gcc-lib/decstation-ultrix/2.3.1/specs
gcc version 2.3.1
 /exp/rcf/share/lib/gcc-lib/decstation-ultrix/2.3.1/cpp -lang-c -v
-undef -D__GNUC__=2 -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD
-D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix
-D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__
-D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__
-D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD
-D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix
-D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C ../../../test/bugs/macro.c macro.i
GNU CPP version 2.3.1 [AL 1.1, MM 28] DECstation running ultrix
 /exp/rcf/share/lib/gcc-lib/decstation-ultrix/2.3.1/cc1 macro.i -quiet
-dumpbase macro.c -version -o macro.s
GNU C version 2.3.1 [AL 1.1, MM 28] DECstation running ultrix compiled
by GNU C version 2.3.1.
../../../test/bugs/macro.c: In function `main':
../../../test/bugs/macro.c:15: undefined or invalid # directive
../../../test/bugs/macro.c:17: undefined or invalid # directive


CPP output:

/* Start ---------------------------------------------------------------- */
#1 "../../../test/bugs/macro.c"








main ()
{

  do { 
	     {
	       printf ("Hello world 1!\n");
#ifdef NOTDEFINED
	       
#endif
	       printf ("Hello world 2!\n");
	     }; } while (0) ;

  return 0;
}
/* End ------------------------------------------------------------------ */

Please feel free to contact me about this if I can provide more
information. I can be reached via email at pasieka@cs.umass.edu or by
phone at 413/545-2447.

-- Michael

Newsgroups: gnu.gcc.bug