[PATCH] reject invalid flexarrays even in anonymous structs (PR 93753)
Jason Merrill
jason@redhat.com
Wed Feb 19 23:51:00 GMT 2020
On 2/18/20 12:06 AM, Martin Sebor wrote:
> The improved checking of flexible array members committed in r231665
> (and later) deliberately excluded anonymous structs and unions
> (unnamed members of types with no tags) to allow a harmless extension
> that was accepted by G++ prior to the change. However, being overly
> broad, the exemption prevents flexible array members that are invalid
> for other reasons from being diagnosed in these contexts. That in
> turn leads to a subset of such cases causing ICEs downstream.
>
> The attached trivial patch tightens up the conditions under which
> this extension is accepted: it only considers such structs when they
> are members, thus eliminating the ICE.
The comment says,
Ignore anonymous structs and unions whose members are
considered to be members of the enclosing class and thus will
be diagnosed when checking it.
Certainly if there is no enclosing class this is not the case, so the
patch is an improvement. Do we already properly diagnose an unnamed
struct used to declare a data member?
Jason
More information about the Gcc-patches
mailing list