[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-07-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek  ---
Why has this been backported to 15 branch?
Generally accepts-invalid bugs aren't backported to release branches, or
similar changes which cause rejection of more code than was accepted before on
the branch, or more warnings than before on the branch.
It is ok to e.g. error on something we'd ICEd on before.
The reason for this is so that people need to do (if possible) porting of their
codes to a newer gcc version just once a year for major releases, so that they
don't need to repeat it every week or month again.

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-07-30 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

--- Comment #5 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Qing Zhao :

https://gcc.gnu.org/g:722aa418df94d85eecb7500ec9c38384c557338d

commit r15-10159-g722aa418df94d85eecb7500ec9c38384c557338d
Author: Qing Zhao 
Date:   Wed Jul 30 14:49:12 2025 +

C: Flex array in union followed by a structure field is not reported
[PR120354]

There is only one last_field for a structure type, but there might
be multiple last_fields for a union type, therefore we should ORed
the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of
a union type.

PR c/120354

gcc/c/ChangeLog:

* c-decl.cc (finish_struct): Or the results for
TYPE_INCLUDES_FLEXARRAY.

gcc/testsuite/ChangeLog:

* gcc.dg/pr120354.c: New test.

(cherry picked from commit 70418e6c0120cfce33ab69628602dfdadbed683a)

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-05-30 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

--- Comment #4 from GCC Commits  ---
The master branch has been updated by Qing Zhao :

https://gcc.gnu.org/g:70418e6c0120cfce33ab69628602dfdadbed683a

commit r16-1018-g70418e6c0120cfce33ab69628602dfdadbed683a
Author: Qing Zhao 
Date:   Thu May 29 15:59:41 2025 +

C: Flex array in union followed by a structure field is not reported
[PR120354]

There is only one last_field for a structure type, but there might
be multiple last_fields for a union type, therefore we should ORed
the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of
a union type.

PR c/120354

gcc/c/ChangeLog:

* c-decl.cc (finish_struct): Or the results for
TYPE_INCLUDES_FLEXARRAY.

gcc/testsuite/ChangeLog:

* gcc.dg/pr120354.c: New test.

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-05-27 Thread qinzhao at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

qinzhao at gcc dot gnu.org changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2025-05-27
 Status|UNCONFIRMED |ASSIGNED

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-05-27 Thread qinzhao at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

--- Comment #3 from qinzhao at gcc dot gnu.org ---
(In reply to Ella Ma from comment #2)
> Sorry, I made a mistake when making the example.
> This problem happens when the flex-array member is not the last, **and the
> members below it are in a record type**. (GCC will report if they are in
> integer types)
> 
> Which means, in the original example, the `y` elements in `union X` and
> `union Y` should be in a struct or union (it is also not reported even if
> the struct or union is empty), rather than `int`.
> 
> Details and comparison with Clang in https://godbolt.org/z/zjPY9z5E7, please
> ignore the previous link to godbolt.

Yes, I can repeat this issue.

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-05-22 Thread alansnape3058 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

--- Comment #2 from Ella Ma  ---
Sorry, I made a mistake when making the example.
This problem happens when the flex-array member is not the last, **and the
members below it are in a record type**. (GCC will report if they are in
integer types)

Which means, in the original example, the `y` elements in `union X` and `union
Y` should be in a struct or union (it is also not reported even if the struct
or union is empty), rather than `int`.

Details and comparison with Clang in https://godbolt.org/z/zjPY9z5E7, please
ignore the previous link to godbolt.

[Bug c/120354] Flexible array union in the middle is not reported by -Wflex-array-member-not-at-end option when flexible array member is not the last one

2025-05-19 Thread alansnape3058 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

--- Comment #1 from Ella Ma  ---
Details and comparison with Clang in https://godbolt.org/z/h8qYhK6rY