[Bug preprocessor/125048] [13/14/15 Regression] ICE on repeated usage of ##__VA_OPT__() since r10-6633
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 27 14:12:06 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125048
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:5f123762acabd8c28ab469b30933d4d27d15a949
commit r15-11519-g5f123762acabd8c28ab469b30933d4d27d15a949
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Aug 6 11:01:15 2026 +0200
libcpp: Fix up ICE with __VA_OPT__ [PR125048]
The following testcase ICEs, because we call linemap_enter_macro
and remember what it returned and then in a loop sometimes call
vaopt_state::update (src) which can call expand_arg which under the
hood can reallocate the pfile->line_table->info_macro.maps array.
As linemap_enter_macro returns a pointer into that array, if the
array is reallocated, we then dereference the freed memory.
The following patch fixes it by remembering the offset into the
pfile->line_table->info_macro.maps array and when we could have called
expand_arg, updates the map variable so that it is correct even after
possible reallocation.
2026-04-28 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/125048
* macro.cc (replace_args): Remember the position of map
in the pfile->line_table->info_macro.maps array and if vostate
is DROP, recompute map pointer as expand_arg call could have
reallocated the pfile->line_table->info_macro.maps array.
* c-c++-common/cpp/va-opt-11.c: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7b87f41690d46b869c21d0d0537b766698da3827)
More information about the Gcc-bugs
mailing list