gcc preprocessor bug ?

Nilmoni Deb ndeb@ece.cmu.edu
Wed Apr 9 20:51:00 GMT 2003


Hi,
	I compiled the following program with both gcc-2.95.3 and
gcc-3.2.1 and in both cases it compiled ok and ran ok (printed "i=10").

#include<stdio.h>

#define MAX 10;

main()
{
int i=MAX;
printf("i=%d\n", i);

/* int *j=0;
j = (int*)malloc(MAX*sizeof(int)); */
}

Now, if I uncomment the last two lines, then the compiler gives the error:
file.c:11: parse error before ';' token

Now, if I remove the ";" from the #define statement, it compiles ok.

Shouldn't the preprocessor always give an error for a #define statement
ending in ";" ? It seems it does not do so consistently.


thanks 
- Nil




More information about the Gcc-bugs mailing list