Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong macro expansion (multiple macros) #185

Open
danmar opened this issue Dec 14, 2019 · 0 comments
Open

wrong macro expansion (multiple macros) #185

danmar opened this issue Dec 14, 2019 · 0 comments
Labels

Comments

@danmar
Copy link
Owner

danmar commented Dec 14, 2019

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 , "" ) ;

@danmar danmar added the bug label Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant