diamond@csl.sony.co.jp (Norman Diamond) (10/11/89)
In article <11163@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >... as a general design principle the preprocessor is not required to >back up, apart from the quite limited case of rescanning the >replacement buffer. Thank you for answering my question, but I think that your answer might be a bit too broad. Section 3.8.3.4 (Dec. 7 '88) says that after replacement, the replacement buffer must be rescanned WITH THE REST OF THE SOURCE FILE'S PREPROCESSING TOKENS. For example, consider: #include <stdio.h> #define mf1(x) printf("Hello, world.\n") #define m2 (z); main(){ mf1 m2 } After "m2" changes into "(z);", it must be rescanned with the rest of the source file's preprocessing tokens. At this time mf1 must be recognized as a function-like macro call. The preprocessor MUST BACK UP EARLIER THAN THE REPLACEMENT BUFFER. I will bet that every pre-ANSI compiler/preprocessor would have rejected the above program. But ANSI requires it to print "Hello, world.\n". In fact I think I can construct a few perverse macros, which will make the preprocessor take EXPONENTIAL TIME in proportion to the length of the program. -- Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work) The above opinions are inherited by your machine's init process (pid 1), after being disowned and orphaned. However, if you see this at Waterloo or Anterior, then their administrators must have approved of these opinions.