If we start some lines of code by using a #if... or #ifndef or #if define "first" line, a line of the sort #ekse (that is a typo and was meant to read #else) is ignored and all the code up to the final #endif is ignored. There should be a syntax warning of the same kind as if we start the construct with a #if or #ifndef that is "true". Environment: System: SunOS wminrts 5.8 Generic_108528-11 sun4u sparc SUNW,Ultra-60 Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 Configured with: /diska/home/vltmgr/VLTSW/PRODUCTS/gnu/SunOS-5.8/gcc-3.2.1/configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c++,f77 --prefix=/vlt/APR2003/gnu How-To-Repeat: Source-code t.c: int main(int argc, char *argv[]) { #if 0 int dummy= 1 ; #ekse int dummy= 0 ; #endif return 0 ; } compiled with gcc -save-temps -v -Wall -pedantic -o t t.c Reading specs from /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs Configured with: /diska/home/vltmgr/VLTSW/PRODUCTS/gnu/SunOS-5.8/gcc-3.2.1/configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c++,f77 --prefix=/vlt/APR2003/gnu Thread model: posix gcc version 3.2.1 /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__PRAGMA_REDEFINE_EXTNAME -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__PRAGMA_REDEFINE_EXTNAME -D__sparc -D__sun -D__unix -Asystem=unix -Asystem=svr4 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__WCHAR_TYPE__=long int -D__WINT_TYPE__=long int -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc t.c -Wall -pedantic t.i GNU CPP version 3.2.1 (cpplib) (sparc ELF) ignoring nonexistent directory "/vlt/APR2003/gnu/sparc-sun-solaris2.8/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /vlt/APR2003/gnu/include /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/include /usr/include End of search list. /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -Wall -pedantic -version -o t.s GNU CPP version 3.2.1 (cpplib) (sparc ELF) GNU C version 3.2.1 (sparc-sun-solaris2.8) compiled by GNU C version 3.2.1. /usr/ccs/bin/as -V -Qy -s -o t.o t.s /usr/ccs/bin/as: Sun WorkShop 6 99/08/18 /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy -o t /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/crt1.o /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/crti.o /usr/ccs/lib/values-Xa.o /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/crtbegin.o -L/vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1 -L/vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/../../../../sparc-sun-solaris2.8/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/../../.. t.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/crtend.o /vlt/APR2003/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/crtn.o ld: Software Generation Utilities - Solaris-ELF (4.0) preprocessor output: # 1 "t.c" # 1 "<built-in>" # 1 "<command line>" # 1 "t.c" int main(int argc, char *argv[]) { return 0 ; }
Fix: No known fix but to check carefully all the #e.. kinds of preprocessor lines. Note that #if 1 .... #ekse .... #endif reports a syntax error, and this is what one would also expect from the #if 0 .... #ekse .... #endif version..
The standard requires that unknown preprocessing directives are ignored. Since the text inside the non-taken branch of an if directive is ignored except for breaking it up into preprocessing tokens the example is completely well formed.
*** Bug 14986 has been marked as a duplicate of this bug. ***