[Bug c++/123738] [16 Regression] "is not a constant expression" in code using a string literal operator template since r16-6431
nshead at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 24 01:17:01 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123738
--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Created attachment 63479
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63479&action=edit
pr123738.patch
Issue is in 'cp_fold_non_odr_use_1', when called to fold away a reference,
considers the use to not be an lvalue and so 'maybe_constant_value' folds all
the way through the nested INDIRECT_REF to a prvalue.
The attached (somewhat tested, so far just dg.exp) fix seems to solve the
issue, but I'm not sure if there's a better way to teach
cxx_eval_outermost_constant_expr that we want an lvalue evaluation, or whether
we should provide a new function specifically for folding reference usages.
More information about the Gcc-bugs
mailing list