cpp and compliance to C99

Thomas Pornin Thomas.Pornin@ens.fr
Fri Oct 20 03:15:00 GMT 2000


On Thu, Oct 19, 2000 at 10:32:57PM +0100, Neil Booth wrote:
> Appendix J to the C99 standard states (under "unspecified
> behaviour"):-

Well, this appendix is mysterious. It is not normative but is supposed
to give explanations about the standard; English is not my mother
language, but I found the wording of the standard much clearer than the
appendix.

I personnaly think that, notwithstanding this appendix, the second
behaviour is the only correct one; however:
-- the mere presence of the appendix somehow relaxes the rule: since it
is part of the "standard document", no one can be blamed for implementing
the nesting in another way
-- considering the call as unnested as long as some new token is required
to complete the macro call, will not induce infinite loop, and this was
the reason why the nesting rule was introduced in the first place

Therefore, whatever behaviour is chosen for gcc will be fine. The reason
I sent my bug-report is that I have written my own cpp and it did not
agree with the GNU cpp on the two examples I sent (which were actually
quoted from some guy on comp.std.c, who had also some trouble making it
out). At that moment, I had not seen appendix J, only the 6.10 part of
the standard, and I was almost sure the GNU cpp behaviour was wrong.
Besides, I had used the GNU cpp as a reference for my development (to
see if I got it right) and such a discrepancy was troublesome.

For now, I will stick to the second behaviour, which gives this:
> glue (1,2)
> c(c)(c)
> a(x)
> 1+f(2)

but if GNU cpp does not agree, I do not mind anymore. I think it can
keep its old behaviour, or switch the the other, without any visible
consequence for any past, present or future real-life code.

Thanks for your time and efforts anyway,


	--Thomas Pornin


More information about the Gcc-bugs mailing list