Newsgroups: comp.os.minix
Subject: Compiler bug?
Summary: Macro expansion in ACK involving a conditional statement. 
Organization: Syracuse University, Syracuse
Keywords: Minix, ACK, C-Kermit
From: mcconnel@hydra.syr.edu (Terry R. McConnell)
NNTP-Posting-Host: hydra-1.syr.edu
Message-ID: <369a151b.0@news.syr.edu>
Date: 11 Jan 1999 10:13:31 -0500
X-Trace: 11 Jan 1999 10:13:31 -0500, hydra-1.syr.edu
Lines: 41
Path: news.adfa.oz.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!uunet!in4.uu.net!falcon.america.net!newsfeed.atl!news.maxwell.syr.edu!news.syr.edu!hydra.syr.edu!mcconnel

I've been working on porting the latest C-Kermit (7.0, build 196 beta) to
Minix 2.0 and have encounterd a bit of odd behavior on the part of ACK. I
wonder if anyone else has observed this? Literally dozens of places in
the source code the macro "bleep('\07')" occurs. Most of the time it causes
no trouble, but in several places there is a construction of the following
form:

if( some condition ) {

	/* stuff */
}
else bleep('\07');

This produces the compiler error: "else deleted". Surrounding the bleep with
brackets, as in { bleep('\07'); } fixes the problem.

Ok, at this point everybody is saying to themselves, "obviously the problem
is that bleep gets expanded into multiple statements." But that is NOT what
is happening, or at least it doesn't seem to be. 

With the compiler flags I'm using, bleep('\07') actually gets expanded to
putchar('\07'); This, in turn, is a macro in stdio.h that expands to
fputc('\07',stdout), which, in turn, is a macro that gets expanded to a 
certain conditional statement (see stdio.h for details.)  

Running cc -E on the offending source file reveals that the else clause
gets expanded to

else ( condition ? foo : bar );

where the condition, foo, and bar, are exactly what you would expect from
the expansions mentioned above. In particular, the expression in parenthesis
is a perfectly valid conditional statement; yet the expression does not
compile.

Any ideas?
-- 
************************************************************************
Terry R. McConnell   Mathematics/304B Carnegie/Syracuse, N.Y. 13244-1150
trmcconn@syr.edu                            http://barnyard.syr.edu/~tmc 
************************************************************************
