[Bug c++/123737] [15 Regression] GCC produces incorrect output when overloading operator, comma operator since r15-7089
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 8 05:18:16 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123737
--- Comment #13 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:c8637cd2eea50953208a12a5c7a638b92357612a
commit r15-10887-gc8637cd2eea50953208a12a5c7a638b92357612a
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Jan 24 10:38:17 2026 +0100
c++: Fix wrong-code with overloaded comma and CPP_EMBED [PR123737]
In cp_parser_expression for comma operator I've used a short path
where instead of calling build_x_compound_expr #embed number times
it is called just 3 times, for the CPP_NUMBER added by the preprocessor
at the start, last byte from CPP_EMBED and then CPP_NUMBER added by
libcpp at the end, enough to make sure -Wunused-value reports something,
but not bothering users with millions of -Wunused-value warnings
and spending too much compile time on it when they use a very large #embed.
As the following testcases show, that is ok for C or for C++ if the
expression before it is known not to have OVERLOAD_TYPE_P (common case
is INTEGER_TYPE I guess), but doesn't work well in case one uses overloaded
comma operator. In that case we just have to call build_x_compound_expr
the right number of times, even if it is a lot.
I think I don't need to test for !expression, because the preprocessor
should guarantee that CPP_EMBED is preceded by CPP_NUMBER CPP_COMMA
tokens.
2026-01-24 Jakub Jelinek <jakub@redhat.com>
PR c++/123737
* parser.cc (cp_parser_expression): Don't handle CPP_EMBED just
as the last byte in it if expression has or might have overloaded
type. In that case call build_x_compound_expr for each byte
in CPP_EMBED separately.
* g++.dg/cpp/embed-28.C: New test.
* g++.dg/parse/comma3.C: New test.
(cherry picked from commit e2f626b37ef62fcab8667b2a67318c27a8f2a6ca)
More information about the Gcc-bugs
mailing list