public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Richard Biener <rguenther@suse.de>, Kees Cook <keescook@chromium.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	jakub Jelinek <jakub@redhat.com>, martin Sebor <msebor@gmail.com>,
	"joseph@codesourcery.com" <joseph@codesourcery.com>
Subject: Re: [[GCC13][Patch][V3] 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836]
Date: Fri, 26 Aug 2022 13:37:13 +0000	[thread overview]
Message-ID: <14B0C56E-AEBB-4C6B-B487-C6AF5DEC5505@oracle.com> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2208260849000.14286@jbgna.fhfr.qr>



> On Aug 26, 2022, at 4:49 AM, Richard Biener <rguenther@suse.de> wrote:
> 
> On Wed, 17 Aug 2022, Qing Zhao wrote:
> 
>> Use array_at_struct_end_p to determine whether the trailing array
>> of a structure is flexible array member in __builtin_object_size.
> 
> With the discussion about what array_at_struct_end_p actually computes,
> is this now the correct utility for __builtin_object_size or should
> it use a stricter variant?

My understanding is, -fstrict-flex-arrays should control all the GCC analysis consistently, including __bultin_object_size. 
For a standard conforming application, use -fstrict-flex-arrays=3 for the most efficient code. 

Kees, is it okay for Linux Kernel to add -fstrict-flex-arrays in order to enable FORTIFY_SOURCE work better for regular trailing arrays?

Thanks.

Qing
> 
>> gcc/ChangeLog:
>> 
>> 	PR tree-optimization/101836
>> 	* tree-object-size.cc (addr_object_size): Use array_at_struct_end_p
>> 	to determine a flexible array member reference.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>> 	PR tree-optimization/101836
>> 	* gcc.dg/pr101836.c: New test.
>> 	* gcc.dg/pr101836_1.c: New test.
>> 	* gcc.dg/pr101836_2.c: New test.
>> 	* gcc.dg/pr101836_3.c: New test.
>> 	* gcc.dg/pr101836_4.c: New test.
>> 	* gcc.dg/pr101836_5.c: New test.
>> 	* gcc.dg/strict-flex-array-5.c: New test.
>> 	* gcc.dg/strict-flex-array-6.c: New test.
>> ---
>> gcc/testsuite/gcc.dg/pr101836.c            | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/pr101836_1.c          | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/pr101836_2.c          | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/pr101836_3.c          | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/pr101836_4.c          | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/pr101836_5.c          | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/strict-flex-array-5.c | 60 ++++++++++++++++++++++
>> gcc/testsuite/gcc.dg/strict-flex-array-6.c | 60 ++++++++++++++++++++++
>> gcc/tree-object-size.cc                    | 16 +++---
>> 9 files changed, 487 insertions(+), 9 deletions(-)
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836.c
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836_1.c
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836_2.c
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836_3.c
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836_4.c
>> create mode 100644 gcc/testsuite/gcc.dg/pr101836_5.c
>> create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-5.c
>> create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-6.c
>> 
>> diff --git a/gcc/testsuite/gcc.dg/pr101836.c b/gcc/testsuite/gcc.dg/pr101836.c
>> new file mode 100644
>> index 000000000000..efad02cfe899
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836.c
>> @@ -0,0 +1,60 @@
>> +/* -fstrict-flex-arrays is aliased with -ftrict-flex-arrays=3, which is the
>> +   strictest, only [] is treated as flexible array.  */ 
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), 16);
>> +    expect(__builtin_object_size(trailing_1->c, 1), 4);
>> +    expect(__builtin_object_size(trailing_0->c, 1), 0);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/pr101836_1.c b/gcc/testsuite/gcc.dg/pr101836_1.c
>> new file mode 100644
>> index 000000000000..e2931ce1012e
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836_1.c
>> @@ -0,0 +1,60 @@
>> +/* -fstrict-flex-arrays=3 is the strictest, only [] is treated as
>> +   flexible array.  */ 
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=3" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), 16);
>> +    expect(__builtin_object_size(trailing_1->c, 1), 4);
>> +    expect(__builtin_object_size(trailing_0->c, 1), 0);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/pr101836_2.c b/gcc/testsuite/gcc.dg/pr101836_2.c
>> new file mode 100644
>> index 000000000000..78974187721f
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836_2.c
>> @@ -0,0 +1,60 @@
>> +/* When -fstrict-flex-arrays=2, only [] and [0] are treated as flexiable
>> +   arrays.  */
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=2" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), 16);
>> +    expect(__builtin_object_size(trailing_1->c, 1), 4);
>> +    expect(__builtin_object_size(trailing_0->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/pr101836_3.c b/gcc/testsuite/gcc.dg/pr101836_3.c
>> new file mode 100644
>> index 000000000000..0e69388e81fb
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836_3.c
>> @@ -0,0 +1,60 @@
>> +/* When -fstrict-flex-arrays=1, [], [0], and [1] are treated as flexible
>> +   arrays.  */
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=1" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), 16);
>> +    expect(__builtin_object_size(trailing_1->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_0->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/pr101836_4.c b/gcc/testsuite/gcc.dg/pr101836_4.c
>> new file mode 100644
>> index 000000000000..e0025aa9a7b5
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836_4.c
>> @@ -0,0 +1,60 @@
>> +/* when -fstrict-flex-arrays=0, all trailing arrays are treated as
>> +   flexible arrays.  */
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=0" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_1->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_0->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/pr101836_5.c b/gcc/testsuite/gcc.dg/pr101836_5.c
>> new file mode 100644
>> index 000000000000..0ad8bbf693ce
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr101836_5.c
>> @@ -0,0 +1,60 @@
>> +/* -fno-strict-flex-arrays is aliased to -fstrict-flex-arrays=0,
>> +   all trailing arrays are treated as flexible array.  */
>> +/* PR tree-optimization/101836 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fno-strict-flex-arrays" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4];
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1];
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0];
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_1->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_0->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/strict-flex-array-5.c b/gcc/testsuite/gcc.dg/strict-flex-array-5.c
>> new file mode 100644
>> index 000000000000..e474b9ec43fa
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/strict-flex-array-5.c
>> @@ -0,0 +1,60 @@
>> +/* test the combination of attribute strict_flex_arrays and option
>> +   -fstrict-flex-arrays: when both attribute and option specified,
>> +   attribute will have higher priority.  */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=3" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4] __attribute__ ((strict_flex_arrays (0)));
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1] __attribute__ ((strict_flex_arrays (1)));
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0] __attribute__ ((strict_flex_arrays (2)));
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_1->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_0->c, 1), -1);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/strict-flex-array-6.c b/gcc/testsuite/gcc.dg/strict-flex-array-6.c
>> new file mode 100644
>> index 000000000000..b45e7b32f6d1
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/strict-flex-array-6.c
>> @@ -0,0 +1,60 @@
>> +/* test the combination of attribute strict_flex_arrays and option
>> +   -fstrict-flex-arrays: when both attribute and option specified,
>> +   attribute will have higher priority.  */
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -fstrict-flex-arrays=0" } */
>> +
>> +#include <stdio.h>
>> +
>> +#define expect(p, _v) do { \
>> +    size_t v = _v; \
>> +    if (p == v) \
>> +        printf("ok:  %s == %zd\n", #p, p); \
>> +    else \
>> +	{  \
>> +          printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
>> +	  __builtin_abort (); \
>> +	} \
>> +} while (0);
>> +
>> +struct trailing_array_1 {
>> +    int a;
>> +    int b;
>> +    int c[4] __attribute__ ((strict_flex_arrays (1)));
>> +};
>> +
>> +struct trailing_array_2 {
>> +    int a;
>> +    int b;
>> +    int c[1] __attribute__ ((strict_flex_arrays (2)));
>> +};
>> +
>> +struct trailing_array_3 {
>> +    int a;
>> +    int b;
>> +    int c[0] __attribute__ ((strict_flex_arrays (3)));
>> +};
>> +struct trailing_array_4 {
>> +    int a;
>> +    int b;
>> +    int c[];
>> +};
>> +
>> +void __attribute__((__noinline__)) stuff(
>> +    struct trailing_array_1 *normal,
>> +    struct trailing_array_2 *trailing_1,
>> +    struct trailing_array_3 *trailing_0,
>> +    struct trailing_array_4 *trailing_flex)
>> +{
>> +    expect(__builtin_object_size(normal->c, 1), 16);
>> +    expect(__builtin_object_size(trailing_1->c, 1), 4);
>> +    expect(__builtin_object_size(trailing_0->c, 1), 0);
>> +    expect(__builtin_object_size(trailing_flex->c, 1), -1);
>> +}
>> +
>> +int main(int argc, char *argv[])
>> +{
>> +    stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]);
>> +
>> +    return 0;
>> +}
>> diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
>> index 4eb454a4a33b..1f04cb80fd0a 100644
>> --- a/gcc/tree-object-size.cc
>> +++ b/gcc/tree-object-size.cc
>> @@ -604,9 +604,9 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
>> 	  else if (var != pt_var && TREE_CODE (pt_var) == MEM_REF)
>> 	    {
>> 	      tree v = var;
>> -	      /* For &X->fld, compute object size only if fld isn't the last
>> -		 field, as struct { int i; char c[1]; } is often used instead
>> -		 of flexible array member.  */
>> +	      /* For &X->fld, compute object size if fld isn't a flexible array
>> +		 member.  */
>> +	      bool is_flexible_array_mem_ref = false;
>> 	      while (v && v != pt_var)
>> 		switch (TREE_CODE (v))
>> 		  {
>> @@ -633,6 +633,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
>> 			v = NULL_TREE;
>> 			break;
>> 		      }
>> +		    is_flexible_array_mem_ref = array_at_struct_end_p (v);
>> 		    while (v != pt_var && TREE_CODE (v) == COMPONENT_REF)
>> 		      if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0)))
>> 			  != UNION_TYPE
>> @@ -645,12 +646,9 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
>> 			&& TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0)))
>> 			   == RECORD_TYPE)
>> 		      {
>> -			tree fld_chain = DECL_CHAIN (TREE_OPERAND (v, 1));
>> -			for (; fld_chain; fld_chain = DECL_CHAIN (fld_chain))
>> -			  if (TREE_CODE (fld_chain) == FIELD_DECL)
>> -			    break;
>> -
>> -			if (fld_chain)
>> +			/* compute object size only if v is not a
>> +			   flexible array member.  */
>> +			if (!is_flexible_array_mem_ref)
>> 			  {
>> 			    v = NULL_TREE;
>> 			    break;
>> 
> 
> -- 
> Richard Biener <rguenther@suse.de>
> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
> Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
> HRB 36809 (AG Nuernberg)


  reply	other threads:[~2022-08-26 13:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 14:40 [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array Qing Zhao
2022-08-17 14:40 ` [[GCC13][Patch][V3] 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836] Qing Zhao
2022-08-26  8:49   ` Richard Biener
2022-08-26 13:37     ` Qing Zhao [this message]
2022-08-26  8:48 ` [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array Richard Biener
2022-08-26 13:47   ` Qing Zhao
2022-08-29  8:04     ` Richard Biener
2022-08-30 20:30 ` Fwd: " Qing Zhao
2022-08-30 20:30   ` Qing Zhao
2022-08-30 22:53   ` Joseph Myers
2022-08-31 14:00     ` Qing Zhao
2022-08-31 17:21       ` Joseph Myers
2022-08-31 17:21         ` Joseph Myers
2022-08-31 18:55         ` Qing Zhao
2022-08-31 19:24           ` Qing Zhao
2022-08-31 19:29           ` Joseph Myers
2022-08-31 19:29             ` Joseph Myers
2022-08-31 19:47             ` Qing Zhao
2022-08-31 19:52               ` Joseph Myers
2022-08-31 20:06                 ` Qing Zhao
2022-08-31 20:09                   ` Joseph Myers
2022-08-31 20:16                     ` Qing Zhao
2022-08-31 20:35                       ` Qing Zhao
2022-08-31 22:23                         ` Kees Cook
2022-09-01  6:11                           ` Richard Biener
2022-09-04 14:17                             ` Qing Zhao
2022-08-31 22:17                       ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14B0C56E-AEBB-4C6B-B487-C6AF5DEC5505@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=keescook@chromium.org \
    --cc=msebor@gmail.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).