Skip to content

wrong macro expansion (multiple macros) #185

Description

@danmar

First reported in Cppcheck trac here:
https://trac.cppcheck.net/ticket/9538

Code:

#define at(x, y) x##y
#define b(...)                                                                 \
  aa(__VA_ARGS__, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,  \
     , , , , , , , , 2)
#define aa(c, d, a, b, e, f, g, h, ab, ac, i, ad, j, k, l, m, n, o, p, ae, q,  \
           r, s, t, u, v, w, x, y, z, af, ag, ah, ai, aj, ak, al, am, an, ao,  \
           ap)                                                                 \
  ap
#define aq(...) ar(b(__VA_ARGS__), __VA_ARGS__) static_assert(true, "")
#define ar(ap, ...) at(I_, ap)(__VA_ARGS__)
#define I_2(as, a)
aq(a, array);

simplecpp outputs I_2 ( a , array ) static_assert ( true , "" ) ; but gcc -E output is static_assert ( true , "" ) ;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions