[cfe-dev] Macro expansion weirdness (or bug?)
Chris Lattner
clattner at apple.com
Thu Mar 25 11:34:13 PDT 2010
On Mar 25, 2010, at 10:51 AM, Abramo Bagnara wrote:
>
> Expanding this snippet:
>
> #define n(v) v
> #define l X m
> #define m l
> n(m)
>
> clang preprocessor generate three MacroExpands callbacks in this order:
>
> n, m, l
>
> As it can be seen no other expansion are attempted (so to avoid
> recursivity) and everything is fine.
>
> If I remove the X as in:
>
> #define n(v) v
> #define l m
> #define m l
> n(m)
>
> the generated MacroExpands callbacks are in order:
>
> n, m, l, m, l
>
> This seems very strange to me and I guess it a symptom of a bug
> somewhere in macro expansion machinery.
This is expected and is how macro expansion (which is a horrible part of the standard works). However, it could be a problem where the callback isn't invoked as you'd expect it to *shrug*.
-Chris
More information about the cfe-dev
mailing list