This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Varargs macros subtly broken


Jamie Lokier wrote:-

> For other tokens, perhaps C99 requires that the token preceding
> ##__VA_ARGS__ is not deleted, if it is possible to paste them?

C99 has no concept of token deletion like this at all.  It's purely an
extension.  Judging from the C99 rationale that was published, they
considered handling the extra-comma problem, but decided not to do
anything, and it didn't seem like they will in future either.  Zack
and I want to keep it useful for what it was used for, but at minimal
deviation from the standard.

> Perhaps more sensible logic would be to warn if the tokens are
> non-pastable and you did not delete the preceding token?  ", ## rest"
> naturally does not require a warning in that case, but other cases where
> the previous token is not deleted would trigger the warning.  (I don't
> know which cases they are but you alluded to them earlier).

I think that's what we do now.  I doubt any cases other than comma will
cause deletion in the future (they don't now).

> If GCC _has_ to change to comply with a standard, fair enough but I
> think that in this case there is a genuine bug somewhere in the
> preprocessor, to do with nested varargs processing.  My macros happen to
> trigger it.  Hopefully Neil can work out what's going on.

I suspect you're right about it being a bug.  I'll try and simplify the
test-case a bit.  Most can shrink to 2 or 3 simple macros.

Neil.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]