https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86505
Bug ID: 86505 Summary: __builtin_va_arg_pack_len() computes the number of arguments wrongly Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rpirrera at aitek dot it Target Milestone: --- I have found another issue with __builtin_va_arg_pack_len() that happens when the functions that uses __builtin_va_arg_pack() calls another function that uses __builtin_va_arg_pack_len(), the argument len is miscalculated as you can see in the attached example. This was working in GCC version 4.4.7. #include <stdio.h> /*************** TESTBUILTIN BEGIN ****************/ static inline __attribute__(( __always_inline__)) int funA(unsigned int param, ...) { return __builtin_va_arg_pack_len(); } static inline __attribute__(( __always_inline__)) int funB(unsigned int param, ...) { return funA(param, 2, 4, __builtin_va_arg_pack()); } int testBuiltin(void) { int rc = funB(0,1,2); if (rc != 4) { return 1; } return 0; } int main(void) { int rc; rc = testBuiltin(); if (rc == 1) { printf("Test Failed!\n"); return rc; } printf("Test Succeeded!\n"); return rc; } Thank you!