This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: cpplib: line-at-a-time lexing


Zack Weinberg wrote:-

> I happen to think that the C99 requirement that __VA_ARGS__ appear
> only in a replacement list of a variadic macro is utterly bogus, and
> this is a nice demonstration of why.  I wonder, if we just stuck in
> code in all the relevant places to prevent it being used as a name of
> anything, would that cover enough bases to satisfy the diagnostic
> requirement?

We could do, though that'd be quite a lot of places.

The current solution isn't too bad (~15 line subroutine); and you
only pay for it if you actually use __VA_ARGS__; checking everywhere
means you pay something regardless.

As for reproducing the bug; yes.  The problem is when lexing new lines
and we are keeping around the previous tokens for some reason: the only
two cases are looking for the '(' of a funlike macro, or when collecting
arguments.  If, when doing either of these, the buffer overflows, things
can go wrong.

Rather than fix it, I'm hoping to go the whole hog and get the macro
expansion done as well (so clients are given fully expanded token lines).
It'll mean a large diff, but the intermediate stage I posted won't really
reduce the size of that diff, since it goes somewhat at a tangent.

Neil.


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