On Wed, Jan 07, 2026 at 04:11:10PM +0800, Jason Merrill wrote:
> > + f = TREE_OPERAND (f, 0);
> > + f = cxx_eval_constant_expression (ctx, f, vc_prvalue,
> > + non_constant_p, overflow_p,
> > + jump_target);
> > + if (*jump_target || *non_constant_p)
> > + return NULL_TREE;
> > + if (TREE_CODE (f) != CONSTRUCTOR
> > + || TREE_CODE (TREE_TYPE (f)) != ARRAY_TYPE)
>
> I'm a bit surprised this can't ever be STRING_CST.
It is what data._M_u8s.c_str () or data._M_s.c_str () returns, where
c_str is called on either std::string or std::u8string object.
In my limited understanding of std::basic_string, I thought that
c_str will either point into the local buffer inside of the string
object or to a heap allocated array, but neither of those are a STRING_CST,
c_str() on even
std::string s = "abcd";
or
std::string s2 = "veryverylooooooooooooooooooooooooooongstring";
should then result in
&s._M_local_buf[0]
or
&heap_ [0]
or so and be a CONSTRUCTOR of ARRAY_TYPE containing the individual bytes.
Unlike other spots which take a string_view and so can be STRING_CST
or that plus constant etc.
Jakub