Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-07 Thread Qing Zhao via Gcc-patches
> On Jul 7, 2022, at 4:02 AM, Richard Biener wrote: > > On Wed, Jul 6, 2022 at 4:20 PM Qing Zhao wrote: >> >> (Sorry for the late reply, just came back from a short vacation.) >> >>> On Jul 4, 2022, at 2:49 AM, Richard Biener >>> wrote: >>> >>> On Fri, Jul 1, 2022 at 5:32 PM Martin Sebor

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-07 Thread Richard Biener via Gcc-patches
On Wed, Jul 6, 2022 at 4:20 PM Qing Zhao wrote: > > (Sorry for the late reply, just came back from a short vacation.) > > > On Jul 4, 2022, at 2:49 AM, Richard Biener > > wrote: > > > > On Fri, Jul 1, 2022 at 5:32 PM Martin Sebor wrote: > >> > >> On 7/1/22 08:01, Qing Zhao wrote: > >>> > >>> >

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-06 Thread Qing Zhao via Gcc-patches
(Sorry for the late reply, just came back from a short vacation.) > On Jul 4, 2022, at 2:49 AM, Richard Biener wrote: > > On Fri, Jul 1, 2022 at 5:32 PM Martin Sebor wrote: >> >> On 7/1/22 08:01, Qing Zhao wrote: >>> >>> On Jul 1, 2022, at 8:59 AM, Jakub Jelinek wrote: On

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-04 Thread Richard Biener via Gcc-patches
On Fri, Jul 1, 2022 at 5:32 PM Martin Sebor wrote: > > On 7/1/22 08:01, Qing Zhao wrote: > > > > > >> On Jul 1, 2022, at 8:59 AM, Jakub Jelinek wrote: > >> > >> On Fri, Jul 01, 2022 at 12:55:08PM +, Qing Zhao wrote: > >>> If so, comparing to the current implemenation to have all the checking

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Martin Sebor via Gcc-patches
On 7/1/22 08:01, Qing Zhao wrote: On Jul 1, 2022, at 8:59 AM, Jakub Jelinek wrote: On Fri, Jul 01, 2022 at 12:55:08PM +, Qing Zhao wrote: If so, comparing to the current implemenation to have all the checking in middle-end, what’s the major benefit of moving part of the checking into

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 8:59 AM, Jakub Jelinek wrote: > > On Fri, Jul 01, 2022 at 12:55:08PM +, Qing Zhao wrote: >> If so, comparing to the current implemenation to have all the checking in >> middle-end, what’s the >> major benefit of moving part of the checking into FE, and leaving the

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 8:58 AM, Richard Biener wrote: > > On Fri, Jul 1, 2022 at 2:55 PM Qing Zhao wrote: >> >> >> >>> On Jul 1, 2022, at 2:49 AM, Richard Biener >>> wrote: >>> >>> On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wrote: > On Jun 30, 2022, at 1:03 PM, Jakub

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Jakub Jelinek via Gcc-patches
On Fri, Jul 01, 2022 at 12:55:08PM +, Qing Zhao wrote: > If so, comparing to the current implemenation to have all the checking in > middle-end, what’s the > major benefit of moving part of the checking into FE, and leaving the other > part in middle-end? The point is recording early what

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Richard Biener via Gcc-patches
On Fri, Jul 1, 2022 at 2:55 PM Qing Zhao wrote: > > > > > On Jul 1, 2022, at 2:49 AM, Richard Biener > > wrote: > > > > On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wrote: > >> > >> > >> > >>> On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: > >>> > >>> On Thu, Jun 30, 2022 at 03:31:00PM +,

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Qing Zhao via Gcc-patches
> On Jul 1, 2022, at 2:49 AM, Richard Biener wrote: > > On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wrote: >> >> >> >>> On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: >>> >>> On Thu, Jun 30, 2022 at 03:31:00PM +, Qing Zhao wrote: > No, that’s not true. A FIELD_DELC is only

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-07-01 Thread Richard Biener via Gcc-patches
On Thu, Jun 30, 2022 at 9:30 PM Qing Zhao wrote: > > > > > On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: > > > > On Thu, Jun 30, 2022 at 03:31:00PM +, Qing Zhao wrote: > >>> No, that’s not true. A FIELD_DELC is only shared for cv variants of a > >>> structure. > >> > >> Sorry for my

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 30, 2022, at 1:03 PM, Jakub Jelinek wrote: > > On Thu, Jun 30, 2022 at 03:31:00PM +, Qing Zhao wrote: >>> No, that’s not true. A FIELD_DELC is only shared for cv variants of a >>> structure. >> >> Sorry for my dump questions: >> >> 1. What do you mean by “cv variants” of a

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Jakub Jelinek via Gcc-patches
On Thu, Jun 30, 2022 at 03:31:00PM +, Qing Zhao wrote: > > No, that’s not true. A FIELD_DELC is only shared for cv variants of a > > structure. > > Sorry for my dump questions: > > 1. What do you mean by “cv variants” of a structure? const/volatile qualified variants. So > 2. For the

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 30, 2022, at 10:24 AM, Richard Biener > wrote: > > > >> Am 30.06.2022 um 16:08 schrieb Qing Zhao via Gcc-patches >> : >> >>  >> >>> On Jun 29, 2022, at 5:14 PM, Martin Sebor wrote: >>> >>> On 6/28/22 13:01, Qing Zhao wrote: > On Jun 28, 2022, at 2:49 PM, Jakub Jelinek

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Richard Biener via Gcc-patches
> Am 30.06.2022 um 16:08 schrieb Qing Zhao via Gcc-patches > : > >  > >> On Jun 29, 2022, at 5:14 PM, Martin Sebor wrote: >> >> On 6/28/22 13:01, Qing Zhao wrote: On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote:

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-30 Thread Qing Zhao via Gcc-patches
> On Jun 29, 2022, at 5:14 PM, Martin Sebor wrote: > > On 6/28/22 13:01, Qing Zhao wrote: >>> On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote: > On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: > >

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-29 Thread Martin Sebor via Gcc-patches
On 6/28/22 13:01, Qing Zhao wrote: On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote: On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote: Because the flag just tells

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-29 Thread Qing Zhao via Gcc-patches
Hi, Jakub and Joseph: > On Jun 28, 2022, at 12:43 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:59:22PM +, Qing Zhao via Gcc-patches wrote: >>> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 03:03:12PM +, Qing Zhao wrote: 2. Then

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 2:49 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote: >> >> >>> On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote: > Because the flag just tells whether some

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 28, 2022 at 06:29:01PM +, Qing Zhao wrote: > > > > On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: > > > > On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote: > >>> Because the flag just tells whether some array shouldn't be treated as > >>> (poor man's) > >>>

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 2:22 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote: >>> Because the flag just tells whether some array shouldn't be treated as >>> (poor man's) >>> flexible array member. We still need to find out if some FIELD_DECL is to >>> be

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 28, 2022 at 06:15:58PM +, Qing Zhao wrote: > > Because the flag just tells whether some array shouldn't be treated as > > (poor man's) > > flexible array member. We still need to find out if some FIELD_DECL is to > > be treated like a flexible array member, which is a minority of

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 12:43 PM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:59:22PM +, Qing Zhao via Gcc-patches wrote: >>> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: >>> >>> On Tue, Jun 28, 2022 at 03:03:12PM +, Qing Zhao wrote: 2. Then replace all

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 28, 2022 at 03:59:22PM +, Qing Zhao via Gcc-patches wrote: > > On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: > > > > On Tue, Jun 28, 2022 at 03:03:12PM +, Qing Zhao wrote: > >> 2. Then replace all “array_at_struct_end_p” with using DECL_NOT_FLEXARRAY > >> in GCC, adding

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Martin Sebor via Gcc-patches
On 6/28/22 01:16, Richard Biener wrote: On Mon, Jun 27, 2022 at 4:20 PM Qing Zhao via Gcc-patches wrote: Hi, Per our discussion in the bug report, I came up with the following patch: === PR101836: Add a new option -fstrict-flex-array[=n] Add the new option and use it in

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
> On Jun 28, 2022, at 11:08 AM, Jakub Jelinek wrote: > > On Tue, Jun 28, 2022 at 03:03:12PM +, Qing Zhao wrote: >> 2. Then replace all “array_at_struct_end_p” with using DECL_NOT_FLEXARRAY in >> GCC, adding new testing cases > > No, IMHO array_at_struct_end_p should stay as is, just test

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 28, 2022 at 03:03:12PM +, Qing Zhao wrote: > 2. Then replace all “array_at_struct_end_p” with using DECL_NOT_FLEXARRAY in > GCC, adding new testing cases No, IMHO array_at_struct_end_p should stay as is, just test this extra flag too. Jakub

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Qing Zhao via Gcc-patches
Hi, Richard, > On Jun 28, 2022, at 3:16 AM, Richard Biener > wrote: > > On Mon, Jun 27, 2022 at 4:20 PM Qing Zhao via Gcc-patches > wrote: >> >> Hi, >> >> Per our discussion in the bug report, I came up with the following patch: >> >> === >> >> PR101836: Add a new option

Re: [GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-28 Thread Richard Biener via Gcc-patches
On Mon, Jun 27, 2022 at 4:20 PM Qing Zhao via Gcc-patches wrote: > > Hi, > > Per our discussion in the bug report, I came up with the following patch: > > === > > PR101836: Add a new option -fstrict-flex-array[=n] > > Add the new option and use it in __builtin_object_size. > > Treat the

[GCC 13][PATCH] PR101836: Add a new option -fstrict-flex-array[=n] and use it in __builtin_object_size

2022-06-27 Thread Qing Zhao via Gcc-patches
Hi, Per our discussion in the bug report, I came up with the following patch: === PR101836: Add a new option -fstrict-flex-array[=n] Add the new option and use it in __builtin_object_size. Treat the trailing array of a structure as a flexible array member in a stricter way. The value of