https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86505
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 Status|UNCONFIRMED |ASSIGNED Known to work| |4.4.7 Version|unknown |8.1.0 Keywords| |wrong-code Last reconfirmed| |2018-07-12 Component|c |middle-end Ever confirmed|0 |1 Summary|__builtin_va_arg_pack_len() |[6/7/8/9 Regression] |computes the number of |__builtin_va_arg_pack_len() |arguments wrongly |computes the number of | |arguments wrongly Target Milestone|--- |6.5 Known to fail| |4.5.2, 6.4.0, 7.3.0, 8.1.0, | |9.0 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. This is because funA is inlined as follows __attribute__((always_inline)) funB (unsigned int param) { int D.1995; int D.1994; unsigned int param; int D.1981; int _4; int _6; <bb 2> : param_5 = param_2(D); _6 = __builtin_va_arg_pack_len (); <bb 3> : <L1>: _7 = _6; _4 = _7; <bb 4> : <L0>: return _4; } here obviously while va_arg_pack_len is correctly not resolved it needs to be adjusted by the additional variadic args that got passed to funA. The testcase is somewhat artificial because we refuse to inline once variadic args are accessed in the callee but still it shows a bug. I will try to fix that.