Hi Richard,

On 26.09.23 08:49, Richard Biener wrote:
On Mon, 25 Sep 2023, Tobias Burnus wrote:
First, the following gives only a -pedantic warning and not a
-Wflex-array-member-not-at-end:

   struct t { int b; int x[]; };
   struct q { int b; struct t a[2]; int c; };

warning: invalid use of structure with flexible array member [-Wpedantic]

If I remove the "[2]", it shows additionally:
   warning: structure containing a flexible array member is not at the end of
   another structure [-Wflex-array-member-not-at-end]

It seems as if it should print latter warning also inside the struct.
I think an array element with a flex array is invalid and this is what
is diagnosed here.  Maybe it should say ' as array element'

My issue is not that it is invalid – but that it is *not* diagnosed
by Qing's -Wflex-array-member-not-at-end

And I believe it should be diagnosed.

(The example is diagnosed when changing 'struct t c[2]' to 'struct t c'
(i.e. array→scalar); it is also diagnosed by "-pedantic", but that diagnoses 
too much.)

* * *

Additionally in previous email:

* RFC whether -Wflex-array-member-not-at-end should be enabled by, e.g. -Wall,
  if we want to deprecate this feature

* Proposed wording improvement for the associated entry in the release notes 
(gcc-14/changes.html)

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955

Reply via email to