public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/77650] struct with a nested flexible array followed by another member accepted
       [not found] <bug-77650-4@http.gcc.gnu.org/bugzilla/>
@ 2022-12-02 16:36 ` siddhesh at gcc dot gnu.org
  2023-06-12 15:51 ` qinzhao at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: siddhesh at gcc dot gnu.org @ 2022-12-02 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |siddhesh at gcc dot gnu.org

--- Comment #6 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> ---
*** Bug 107951 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/77650] struct with a nested flexible array followed by another member accepted
       [not found] <bug-77650-4@http.gcc.gnu.org/bugzilla/>
  2022-12-02 16:36 ` [Bug c/77650] struct with a nested flexible array followed by another member accepted siddhesh at gcc dot gnu.org
@ 2023-06-12 15:51 ` qinzhao at gcc dot gnu.org
  2023-06-27 14:25 ` qinzhao at gcc dot gnu.org
  2023-06-29 17:16 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2023-06-12 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from qinzhao at gcc dot gnu.org ---
the patch for this documentation change in GCC has been posted and approved
at:https://gcc.gnu.org/pipermail/gcc-patches/2023-May/620148.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/77650] struct with a nested flexible array followed by another member accepted
       [not found] <bug-77650-4@http.gcc.gnu.org/bugzilla/>
  2022-12-02 16:36 ` [Bug c/77650] struct with a nested flexible array followed by another member accepted siddhesh at gcc dot gnu.org
  2023-06-12 15:51 ` qinzhao at gcc dot gnu.org
@ 2023-06-27 14:25 ` qinzhao at gcc dot gnu.org
  2023-06-29 17:16 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2023-06-27 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from qinzhao at gcc dot gnu.org ---
for record purpose, the code in glibc has already been fixed. 
https://gcc.gnu.org/pipermail/gcc-patches/2023-February/611220.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/77650] struct with a nested flexible array followed by another member accepted
       [not found] <bug-77650-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-06-27 14:25 ` qinzhao at gcc dot gnu.org
@ 2023-06-29 17:16 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-29 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Qing Zhao <qinzhao@gcc.gnu.org>:

https://gcc.gnu.org/g:070a6bf0bdc6761ad77ac97404c98f00a7007d54

commit r14-2197-g070a6bf0bdc6761ad77ac97404c98f00a7007d54
Author: Qing Zhao <qing.zhao@oracle.com>
Date:   Thu Jun 29 17:07:26 2023 +0000

    Update documentation to clarify a GCC extension [PR c/77650]

    on a structure with a C99 flexible array member being nested in
    another structure.

    "The GCC extension accepts a structure containing an ISO C99 "flexible
array
    member", or a union containing such a structure (possibly recursively)
    to be a member of a structure.

     There are two situations:

       * A structure containing a C99 flexible array member, or a union
         containing such a structure, is the last field of another structure,
         for example:

              struct flex  { int length; char data[]; };
              union union_flex { int others; struct flex f; };

              struct out_flex_struct { int m; struct flex flex_data; };
              struct out_flex_union { int n; union union_flex flex_data; };

         In the above, both 'out_flex_struct.flex_data.data[]' and
         'out_flex_union.flex_data.f.data[]' are considered as flexible
         arrays too.

       * A structure containing a C99 flexible array member, or a union
         containing such a structure, is not the last field of another
structure,
         for example:

              struct flex  { int length; char data[]; };

              struct mid_flex { int m; struct flex flex_data; int n; };

         In the above, accessing a member of the array
'mid_flex.flex_data.data[]'
         might have undefined behavior.  Compilers do not handle such a case
         consistently, Any code relying on this case should be modified to
ensure
         that flexible array members only end up at the ends of structures.

         Please use the warning option '-Wflex-array-member-not-at-end' to
         identify all such cases in the source code and modify them.  This
extension
         is now deprecated.
    "

            PR c/77650

    gcc/c-family/ChangeLog:

            * c.opt: New option -Wflex-array-member-not-at-end.

    gcc/c/ChangeLog:

            * c-decl.cc (finish_struct): Issue warnings for new option.

    gcc/ChangeLog:

            * doc/extend.texi: Document GCC extension on a structure containing
            a flexible array member to be a member of another structure.

    gcc/testsuite/ChangeLog:

            * gcc.dg/variable-sized-type-flex-array.c: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-29 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-77650-4@http.gcc.gnu.org/bugzilla/>
2022-12-02 16:36 ` [Bug c/77650] struct with a nested flexible array followed by another member accepted siddhesh at gcc dot gnu.org
2023-06-12 15:51 ` qinzhao at gcc dot gnu.org
2023-06-27 14:25 ` qinzhao at gcc dot gnu.org
2023-06-29 17:16 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).