https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93314
rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org>
---
Hmm, yeah. Before the patch we silently accepted the code
and generated an unconditional trap for a null dereference,
which doesn't sound right either. This is because we used
to fold the dummy object pointer (represented using an
INTEGER_CST with void_type) into a normal null pointer.
Where should this be trapped? The error for accessing
a non-static data member is suppressed for sizeof,
and obviously needs to be for sizeof(S::m):
/* DR 613/850: Can use non-static data members without an associated
object in sizeof/decltype/alignof. */
if (is_dummy_object (object) && cp_unevaluated_operand == 0
&& (!processing_template_decl || !current_class_ref))
A see-one-play-one fix would be to force cp_unevaluated_operand
to zero while parsing an array dimension, on the basis that the
dimension should either be constant (standard C++) or can be
evaluated (GNU VLAs). That feels really hackish though...
Should we instead trap this during gimplification? But then
that would probably make:
sizeof(char[sizeof(char[S::m])])
valid, which doesn't sound right either.