https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58969

--- Comment #3 from Kai Tietz <ktietz at gcc dot gnu.org> ---
(In reply to Richard Smith from comment #2)
> (In reply to Kai Tietz from comment #1)
> > Hmm, issue seems to be in too restrictive decl_maybe_constant_var_p 
> > function.
> 
> I don't know how the GCC code is structured, but I don't think that's right;
> that function appears to be checking whether the value of the variable can
> be used in a constant expression. The relevant condition here is whether the
> address of the variable can be used.

hmm, this function has nothing to do with its value.  AFAIU the comment (and
its use) it just checks that a VAR-decl might be a constant.
In general it checks for const and volatile attributes, and assumes for
integral/enumeral typed variables that variable is constant.
So a 'const char *' isn't constant - as just the destination the variable is
pointing to is constant, but not the variable itself.  For a constant array
with trivial destructor, and non-vla size this is different.  The array's name
is indeed a constant address, and its content is constant too.  Of course the a
variable pointing to into an array isn't constant, but the array itself is.

Anyway I might be wrong here

Reply via email to