diff options
author | Qing Zhao <qing.zhao@oracle.com> | 2023-06-29 17:07:26 +0000 |
---|---|---|
committer | Qing Zhao <qing.zhao@oracle.com> | 2023-06-29 17:15:53 +0000 |
commit | 070a6bf0bdc6761ad77ac97404c98f00a7007d54 (patch) | |
tree | 97c11d69ad70de17b6b42880b5372bcd248c7500 /gcc/tree-vect-patterns.cc | |
parent | 3967da96556163d78cbeafe342c16b820aa85799 (diff) | |
download | gcc-070a6bf0bdc6761ad77ac97404c98f00a7007d54.zip gcc-070a6bf0bdc6761ad77ac97404c98f00a7007d54.tar.gz gcc-070a6bf0bdc6761ad77ac97404c98f00a7007d54.tar.bz2 |
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.
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
0 files changed, 0 insertions, 0 deletions