[comp.lang.c] Bug in cpp

maart@cs.vu.nl (Maarten Litmaath) (04/29/88)

We noticed that the following file will pass cpp
without any error message:

#ifdef a
#ifdef b
#ifdef a
#endif
#endif
#else

This isn't supposed to be a feature, is it?

Benno van den Brink (bvdbrin@cs.vu.nl), Maarten Litmaath (maart@cs.vu.nl)
-- 
South-Africa:                         |Maarten Litmaath @ Free U Amsterdam:
           revival of the Third Reich |maart@cs.vu.nl, mcvax!botter!ark!maart

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (05/04/88)

In article <1241@ark.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
| We noticed that the following file will pass cpp
| without any error message:
| 
~ #ifdef a --------+
~ #ifdef b -----+  |
~ #ifdef a --+  |  |
~ #endif ----+  |  |
~ #endif -------+  |
~ #else -----------+

?? looks okay to me. Mind you it a stupid way to do something, has tests
which are not needed, etc, but I see nothing illegal about it. It's
something like doing:
  if (a == 0) {
    if (b == 0) {
      if (a == 0) {
      }
    }
  }
which is also perfectly legal. Moreover, since the preprocessor would
have to keep track of all the code between ifdefs (you could undef it,
too) this speaks of moving common subexpressions out of loops, and
*PLEASE* let's not have a preprecessor with global optimization, okay?
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

maart@cs.vu.nl (Maarten Litmaath) (05/07/88)

In article <10699@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes:
\In article <1241@ark.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
\| We noticed that the following file will pass cpp
\| without any error message:
\| 
\~ #ifdef a --------+
\~ #ifdef b -----+  |
\~ #ifdef a --+  |  |
\~ #endif ----+  |  |
\~ #endif -------+  |
\~ #else -----------+
\
\?? looks okay to me. Mind you it a stupid way to do something, has tests
\which are not needed, etc, but I see nothing illegal about it.
\...

That's not what we were pointing at!
There's a missing "#endif", ain't that right?
Regards.
-- 
South-Africa:                         |Maarten Litmaath @ Free U Amsterdam:
           revival of the Third Reich |maart@cs.vu.nl, mcvax!botter!ark!maart