Re: [PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-29 Thread Qing Zhao
> On May 29, 2024, at 02:57, Richard Biener wrote: > > On Tue, May 28, 2024 at 11:09 PM Qing Zhao wrote: >> >> Thank you for the comments. See my answers below: >> >> Joseph, please see the last question, I need your help on it. Thanks a lot >> for

Re: [PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-29 Thread Qing Zhao
Richard and Joseph: > On May 28, 2024, at 17:09, Qing Zhao wrote: > >>> >>> diff --git a/gcc/varasm.cc b/gcc/varasm.cc >>> index fa17eff551e8..d75b23668925 100644 >>> --- a/gcc/varasm.cc >>> +++ b/gcc/varasm.cc >>> @@ -5082,6

[PATCH v10 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-30 Thread Qing Zhao
Hi, This is the 10th version of the patch. Which is rebased on the latest trunk. Compare with the 9th version, all the difference are in patch #2, including a small C FE change in the routine "digest_init". all others are middle-end changes. please review the changes for the patch #2: updates p

[PATCH v10 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-05-30 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this inf

[PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-30 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This includ

[PATCH v10 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-05-30 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. * gcc.dg/ubsan/flex-array-counted

[PATCH v10 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-05-30 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code. gcc/c/C

[PATCH v10 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-05-30 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-30 Thread Qing Zhao
> On May 30, 2024, at 15:43, Joseph Myers wrote: > > On Thu, 30 May 2024, Qing Zhao wrote: > >> In order to make this working, the routine digest_init in c-typeck.cc >> is updated to fold calls to .ACCESS_WITH_SIZE to its first argument >> when require_

Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-31 Thread Qing Zhao
> On May 31, 2024, at 08:58, Richard Biener wrote: > > On Thu, 30 May 2024, Qing Zhao wrote: > >> Including the following changes: >> * The definition of the new internal function .ACCESS_WITH_SIZE >> in internal-fn.def. >> * C FE converts every r

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-31 Thread Qing Zhao
> On May 23, 2024, at 07:46, Richard Biener wrote: > > On Wed, May 22, 2024 at 8:53 PM Qing Zhao wrote: >> >> >> >>> On May 22, 2024, at 03:38, Richard Biener >>> wrote: >>> >>> On Tue, May 21, 2024 at 11:36 PM David Mal

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-03 Thread Qing Zhao
> On Jun 3, 2024, at 02:29, Richard Biener wrote: > > On Fri, May 31, 2024 at 11:23 PM Qing Zhao wrote: >> >> >> >>> On May 23, 2024, at 07:46, Richard Biener >>> wrote: >>> >>> On Wed, May 22, 2024 at 8:53 PM Qing Zhao wr

Re: [PATCH] testsuite: Fix fam-in-union-alone-in-struct-2.c with unsigned char [PR116148]

2024-08-09 Thread Qing Zhao
Hi, Kewen, Thanks for the patch, LGTM. Qing > On Aug 9, 2024, at 05:50, Kewen.Lin wrote: > > Hi, > > As PR116148#c7 shows, fam-in-union-alone-in-struct-2.c still > fails on hppa which is a BE environment, but by checking more > (also confirmed by John in PR116148#c12), it's due to that > si

Ping * 3: [PATCH v2] Provide more contexts for -Warray-bounds warning messages

2024-08-12 Thread Qing Zhao
:32, Qing Zhao wrote: > > The 2nd ping for the following patch: > > https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657150.html > > thanks. > > Qing > >> On Jul 22, 2024, at 09:01, Qing Zhao wrote: >> >> Hi, Richard, >> >> Could you

Ping: [PATCH v2] Explicitly document that the "counted_by" attribute is only supported in C.

2024-08-12 Thread Qing Zhao
Gentle ping on this simple patch. thanks. Qing > On Aug 5, 2024, at 16:17, Qing Zhao wrote: > > Compared to the first version, the major changes are: > > 1. Changed the error as a warning with -Wattributes per Jakub and Jason's > comments. > 2. Update documentat

[PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-13 Thread Qing Zhao
With the addition of the 'counted_by' attribute and its wide roll-out within the Linux kernel, a use case has been found that would be very nice to have for object allocators: being able to set the counted_by counter variable without knowing its name. For example, given: struct foo { ...

Re: Ping: [PATCH] testsuite: Fix struct size check [PR116155]

2024-08-13 Thread Qing Zhao
> On Aug 13, 2024, at 17:05, Dimitar Dimitrov wrote: > > On Tue, Aug 13, 2024 at 07:34:09PM +0200, Hans-Peter Nilsson wrote: >>> From: Sam James >>> Date: Tue, 13 Aug 2024 18:17:29 +0100 >> >>> Hans-Peter Nilsson writes: >>> I stumbled on this being a regression for cris-elf as well;

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-20 Thread Qing Zhao
> On Aug 20, 2024, at 05:58, Richard Biener wrote: > > On Tue, Aug 13, 2024 at 5:34 PM Qing Zhao wrote: >> >> With the addition of the 'counted_by' attribute and its wide roll-out >> within the Linux kernel, a use case has been found that would be very

.

2024-08-21 Thread Qing Zhao
> On Aug 21, 2024, at 04:44, Richard Biener wrote: > > On Tue, Aug 20, 2024 at 3:41 PM Qing Zhao wrote: >> >> >> >>> On Aug 20, 2024, at 05:58, Richard Biener >>> wrote: >>> >>> On Tue, Aug 13, 2024 at 5:34 PM Qing Zhao wr

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-21 Thread Qing Zhao
(Resend since the previous one has no subject). > On Aug 21, 2024, at 04:44, Richard Biener wrote: > > On Tue, Aug 20, 2024 at 3:41 PM Qing Zhao wrote: >> >> >> >>> On Aug 20, 2024, at 05:58, Richard Biener >>> wrote: >>>

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-21 Thread Qing Zhao
> On Aug 21, 2024, at 10:34, Martin Uecker wrote: > > Am Mittwoch, dem 21.08.2024 um 14:12 + schrieb Qing Zhao: > > ... >> >>> >>>> + if (__builtin_get_counted_by (__p->FAM)) \ >>>> + *(__builtin_get_counted_by(__p->FAM)) = C

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-21 Thread Qing Zhao
> On Aug 21, 2024, at 10:45, Martin Uecker wrote: > > Am Mittwoch, dem 21.08.2024 um 16:34 +0200 schrieb Martin Uecker: >> Am Mittwoch, dem 21.08.2024 um 14:12 +0000 schrieb Qing Zhao: >> >>> >>> Yes, I do feel that the approach __builtin_get_count

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-21 Thread Qing Zhao
> On Aug 21, 2024, at 11:43, Martin Uecker wrote: > > Am Mittwoch, dem 21.08.2024 um 15:24 + schrieb Qing Zhao: >>> >>> But if we changed it to return a void pointer, we could make this >>> a compile-time check: >>> >>> auto ret =

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-22 Thread Qing Zhao
Hi, Bill, Thank you for the info. > On Aug 21, 2024, at 17:36, Bill Wendling wrote: > >> >> Bill, could you please provide a little bit more info on the possibility of >> a new builtin __builtin_has_attribute() in CLANG? >> > From what I gathered, it would require some moderate surgery to

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-22 Thread Qing Zhao
> On Aug 21, 2024, at 17:54, Bill Wendling wrote: > >> if (__builtin_get_counted_by(p->array)) { >>size_t max_value = >> type_max(typeof(*__builtin_get_counted_by(p->array))); >>if (count > type_max) >>...fail cleanly... >>*__builtin_get_counted_by(p->ar

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-22 Thread Qing Zhao
> On Aug 21, 2024, at 18:08, Bill Wendling wrote: > >>> >>> to test. >> >> For the unary operator __counted_by(PTR), “PTR” must have a counted_by >> attribute, if not, there will be a compilation time error. >> >> Then the user could write the following code: >> >> If __builtin_has_att

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-26 Thread Qing Zhao
eneric operator for this purpose. Any comments on this? Thanks a lot for your help. Qing > On Aug 21, 2024, at 11:43, Martin Uecker wrote: > > Am Mittwoch, dem 21.08.2024 um 15:24 +0000 schrieb Qing Zhao: >>> >>> But if we changed it to return a void pointer, we c

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-27 Thread Qing Zhao
> On Aug 26, 2024, at 15:46, Bill Wendling wrote: > > On Wed, Aug 21, 2024 at 8:43 AM Martin Uecker wrote: >> >> Am Mittwoch, dem 21.08.2024 um 15:24 +0000 schrieb Qing Zhao: >>>> >>>> But if we changed it to return a void pointer,

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-27 Thread Qing Zhao
> On Aug 26, 2024, at 16:30, Kees Cook wrote: > > On Mon, Aug 26, 2024 at 07:30:15PM +0000, Qing Zhao wrote: >> Hi, Martin, >> >> Looks like that there is some issue when I tried to use the _Generic for the >> testing cases, and then I narrowed down to a >

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-27 Thread Qing Zhao
> On Aug 26, 2024, at 17:01, Martin Uecker wrote: > > Am Montag, dem 26.08.2024 um 13:30 -0700 schrieb Kees Cook: >> On Mon, Aug 26, 2024 at 07:30:15PM +, Qing Zhao wrote: >>> Hi, Martin, >>> >>> Looks like that there is some issue when I trie

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-27 Thread Qing Zhao
on, Aug 26, 2024 at 07:30:15PM +, Qing Zhao wrote: >>>>> Hi, Martin, >>>>> >>>>> Looks like that there is some issue when I tried to use the _Generic for >>>>> the testing cases, and then I narrowed down to a >>>>> small te

Re: [PATCH v1] Provide new GCC builtin __builtin_get_counted_by [PR116016]

2024-08-29 Thread Qing Zhao
Hi, Thanks for the information. Yes, providing a unary operator similar as __counted_by(PTR) as suggested by multiple people previously is a cleaner approach. Then the programmer will use the following: __builtin_choose_expr( __builtin_has_attribute (__p->FAM, "counted_by”)

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-04 Thread Qing Zhao
> On Jun 4, 2024, at 03:43, Richard Biener wrote: > > On Mon, Jun 3, 2024 at 4:48 PM David Malcolm wrote: >> >> On Mon, 2024-06-03 at 08:29 +0200, Richard Biener wrote: >>> On Fri, May 31, 2024 at 11:23 PM Qing Zhao >>> wrote: >>>> &

Re: "counted_by" and -fanalyzer (was Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.)

2024-06-04 Thread Qing Zhao
> On Jun 4, 2024, at 17:55, David Malcolm wrote: > > On Fri, 2024-05-31 at 13:11 +0000, Qing Zhao wrote: >> >> >>> On May 31, 2024, at 08:58, Richard Biener >>> wrote: >>> >>> On Thu, 30 May 2024, Qing Zhao wrote: >>> >

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 03:26, Richard Biener wrote: > > On Tue, Jun 4, 2024 at 10:31 PM Qing Zhao wrote: >> >> >> >>> On Jun 4, 2024, at 03:43, Richard Biener wrote: >>> >>> On Mon, Jun 3, 2024 at 4:48 PM David Malcolm wrote: >&g

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 13:07, Richard Biener wrote: > > > >> Am 05.06.2024 um 18:39 schrieb Qing Zhao : >> >>  >> >>> On Jun 5, 2024, at 03:26, Richard Biener wrote: >>> >>>> On Tue, Jun 4, 2024 at 10:31 PM Qing Zhao wrote

Re: "counted_by" and -fanalyzer

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 09:49, David Malcolm wrote: > > On Tue, 2024-06-04 at 22:09 +0000, Qing Zhao wrote: >> >> >>> On Jun 4, 2024, at 17:55, David Malcolm >>> wrote: >>> >>> On Fri, 2024-05-31 at 13:11 +, Qing Zhao wrote: >&g

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-07 Thread Qing Zhao
Hi, Richard, > On Jun 5, 2024, at 13:58, Qing Zhao wrote: >> >>>>>>>>> Like this? >>>>>>>>> >>>>>>>>> diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h >>>>>>>>

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-12 Thread Qing Zhao
more complicate testing case that has one basic block copied multiple times by the jump thread, do you have any pointer to such testing cases? Thanks a lot for any help. Qing > On Jun 7, 2024, at 15:13, Qing Zhao wrote: > > Hi, Richard, > >> On Jun 5, 2024, at 13:5

Ping: [PATCH v2] Provide more contexts for -Warray-bounds warning messages

2024-07-22 Thread Qing Zhao
Hi, Richard, Could you please take a look at the patch and let me know any comment you have (especially on the middle-end part)? David, let me know if you have further comment and suggestions. Thanks a lot. Qing > On Jul 12, 2024, at 10:03, Qing Zhao wrote: > > due to code du

Ping * 2: [PATCH v2] Provide more contexts for -Warray-bounds warning messages

2024-07-29 Thread Qing Zhao
The 2nd ping for the following patch: https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657150.html thanks. Qing > On Jul 22, 2024, at 09:01, Qing Zhao wrote: > > Hi, Richard, > > Could you please take a look at the patch and let me know any comment you > have (especi

Re: [PATCH] testsuite: Adjust fam-in-union-alone-in-struct-2.c to support BE [PR116148]

2024-07-31 Thread Qing Zhao
Hi, Kewen, Thanks a lot for fixing this testing case issue. Yes, the change LGTM though I can’t approve it. Qing > On Jul 31, 2024, at 05:22, Kewen.Lin wrote: > > Hi, > > As Andrew pointed out in PR116148, fam-in-union-alone-in-struct-2.c > was designed for little-endian, the recent commit r

[PATCH] Explicitly document that the "counted_by" attribute is only supported in C

2024-08-05 Thread Qing Zhao
As discussed in PR116016:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116016#c48 We should explicitly document this limitation and issue error messages for C++. The "counted_by" attribute currently is only supported in C, mention this explicitly in documentation and also issue error when see "cou

Re: [PATCH] Explicitly document that the "counted_by" attribute is only supported in C

2024-08-05 Thread Qing Zhao
> On Aug 5, 2024, at 09:53, Jakub Jelinek wrote: > > On Mon, Aug 05, 2024 at 01:33:01PM +0000, Qing Zhao wrote: >> As discussed in >> PR116016:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116016#c48 >> >> We should explicitly document this limitation a

Re: [PATCH] Explicitly document that the "counted_by" attribute is only supported in C

2024-08-05 Thread Qing Zhao
> On Aug 5, 2024, at 12:51, Jakub Jelinek wrote: > > On Mon, Aug 05, 2024 at 04:46:09PM +0000, Qing Zhao wrote: >> So, you want me to add counted_by test-suite for C23? (Which should be >> supported) >> Okay, but I will do it in another separate patch since this

Re: [PATCH] Explicitly document that the "counted_by" attribute is only supported in C

2024-08-05 Thread Qing Zhao
On Aug 5, 2024, at 13:54, Jakub Jelinek wrote: On Mon, Aug 05, 2024 at 01:48:25PM -0400, Jason Merrill wrote: On 8/5/24 9:53 AM, Jakub Jelinek wrote: On Mon, Aug 05, 2024 at 01:33:01PM +, Qing Zhao wrote: As discussed in PR116016:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116016#c48 We

Re: [RFC v3 3/3] c: Add __lengthof__() operator

2024-08-05 Thread Qing Zhao
On Aug 5, 2024, at 06:33, Martin Uecker wrote: > > Am Montag, dem 05.08.2024 um 11:50 +0200 schrieb Jakub Jelinek: >> On Mon, Aug 05, 2024 at 11:45:56AM +0200, Alejandro Colomar wrote: >>> [CC += Kees, Qing] >>> >>> Hi Joseph, >>> >>> On Sun, Aug 04, 2024 at 08:34:24PM GMT, Alejandro Colomar wr

[PATCH v2] Explicitly document that the "counted_by" attribute is only supported in C.

2024-08-05 Thread Qing Zhao
Compared to the first version, the major changes are: 1. Changed the error as a warning with -Wattributes per Jakub and Jason's comments. 2. Update documentation accordingly. 3. Move the testing case to g++.dg/ext Add one more new testing case for C++11 Adjust the testing case according t

Re: [RFC v3 3/3] c: Add __lengthof__() operator

2024-08-06 Thread Qing Zhao
On Aug 5, 2024, at 16:59, Alejandro Colomar wrote: The “counted-by” attribute currently is not in the TYPE system, and we plan to add it into the TYPE system later through language standard (or an GCC extension). If that happens, then both the “sizeof” and the “__lengthof__” operators should

Re: [RFC v4 0/4] c: Add __lengthof__ operator

2024-08-06 Thread Qing Zhao
() => array_type_nelts_minus_one() 2: 2bb966a0a89 = 2: 2bb966a0a89 Merge definitions of array_type_nelts_top() 3: d22b5e1c015 ! 3: e2dbfc43b14 c: Add __lengthof__() operator @@ Metadata Author: Alejandro Colomar ## Commit message ## -c: Add __lengthof__() operator +c: Add _

Re: [RFC v4 3/4] c: Add __lengthof__() operator (n2529)

2024-08-06 Thread Qing Zhao
Some comments on the documentation part. (Hopefully, this time my quoting format is good, I checked the email sent back to myself, no formatting issue, but when I checked the emails in the archive, https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659593.html, yst, I see the quoting forma

[PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-12 Thread Qing Zhao
Hi, This is the 9th version of the patch. Compare with the 8th version, the difference are: updates per Joseph's comments: 1. in C FE, add checking for counted_by attribute for the new multiple definitions of the same tag for C23 in the routine "tagged_types_tu_compatible_p". Add a new tes

[PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-12 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this inf

[PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-12 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This includ

[PATCH v9 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-04-12 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code. gcc/c/C

[PATCH v9 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-04-12 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v9 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-04-12 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. * gcc.dg/ubsan/flex-array-counted

[RFC][PATCH v1 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-19 Thread Qing Zhao
Hi, The request for GCC to accept that the C99 flexible array member can be in a union or alone in a struct has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show

[RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or alone in structures. gcc/cp/ChangeLog: * class.cc (diagnose_flexarrays): Change error to pdewarn for the case flexible array members alone in s

[RFC][PATCH v1 1/4] Documentation change

2024-04-19 Thread Qing Zhao
for allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has be

[RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/testsuite/ChangeLog: * gcc.dg/flex-array-in-union-1.c: New test. * gcc.dg/flex-array-in-union-2.c: New test. --- gcc/testsuite/gcc.dg/flex-array-in-union-1.c | 37 + gcc/testsuite/gcc.dg/flex-array-in-union-2.c | 42 2 files changed, 79 ins

[RFC][PATCH v1 4/4] Adjust testcases for flexible array member in union and alone in structure extension.

2024-04-19 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/builtin-clear-padding-3.c: Adjust testcase. * g++.dg/ext/flexary12.C: Likewise. * g++.dg/ext/flexary19.C: Likewise. * g++.dg/ext/flexary2.C: Likewise. * g++.dg/ext/flexary3.C: Likewise. * g++.dg/ext/flexary36.C

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-22 Thread Qing Zhao
> On Apr 19, 2024, at 16:54, Tom Tromey wrote: > >>>>>> Qing Zhao writes: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. >> + >>

Re: [PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-22 Thread Qing Zhao
Thanks a lot. Qing > On Apr 22, 2024, at 16:38, Joseph Myers wrote: > > This version of patch 1/5 is OK for GCC 15. > > -- > Joseph S. Myers > josmy...@redhat.com >

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:04, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. > > "

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:03, Joseph Myers wrote: > > On Tue, 23 Apr 2024, Qing Zhao wrote: > >> However, I am not very confident on the wording of the doc, is the >> current wording good enough for this? Or do you have any suggestion on >> how to make it bett

Re: [RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:53, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/flex-array-in-union-1.c: New test. >> * gcc.dg/flex-array-in-union-2.c: New test. > > There should

Re: [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-23 Thread Qing Zhao
024, at 09:54, Qing Zhao wrote: > > Hi, > > This is the 9th version of the patch. > > Compare with the 8th version, the difference are: > > updates per Joseph's comments: > > 1. in C FE, add checking for counted_by attribute for the new multiple > definitio

Re: [RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:51, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/c/ChangeLog: >> >> * c-decl.cc (finish_struct): Change errors to pedwarns for the cases >> flexible array members in union or alone in structur

[PATCH v2 1/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bu

[PATCH v2 2/3] C and C++ FE changes

2024-04-25 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or al

[PATCH v2 0/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
Hi, This is the 2nd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html) compared to the 1st version, the major difference are: A. C FE updates based on

[PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

Re: [PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
> On Apr 25, 2024, at 10:13, Siddhesh Poyarekar wrote: > > On 2024-04-25 10:06, Qing Zhao wrote: >> gcc/testsuite/ChangeLog: >> * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. >> * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase.

[PATCH v3 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
Hi, This is the 3rd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/650019

[PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bu

[PATCH v3 2/4] C and C++ FE changes

2024-04-30 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or al

[PATCH v3 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-30 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp/ChangeLog: * decl.cc (layout_var_decl): Handle the cases when t

Re: [PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:29, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:45, Qing Zhao wrote: gcc/doc/extend.texi | 34 ++ 1 file changed, 34 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7bf..cba98c8aadd7 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
> On Apr 30, 2024, at 15:52, Jason Merrill wrote: > > On 4/30/24 14:49, Qing Zhao wrote: >>> On Apr 30, 2024, at 15:45, Qing Zhao wrote: >>> >>> >>> >>>>> gcc/doc/extend.texi | 34 ++ >&g

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
On Apr 30, 2024, at 17:55, Kees Cook wrote: On Tue, Apr 30, 2024 at 05:51:20PM -0400, Jason Merrill wrote: On 4/30/24 14:45, Qing Zhao wrote: On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member

[PATCH v4 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 4th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/650019

[PATCH v4 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v4 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bu

[PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases

[PATCH v4 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or al

Re: [PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
On May 1, 2024, at 09:35, Jason Merrill wrote: On 5/1/24 08:19, Qing Zhao wrote: "add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone

[PATCH v5 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 5th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/650019

[PATCH v5 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bu

[PATCH v5 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or al

[PATCH v5 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v5 4/4] Update the C/C++ FEs routine

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the case

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-06 Thread Qing Zhao
Hi, Sebastian, Looks like that the behavior you described is correct. What’s your major concern? ( a little confused). Qing On May 6, 2024, at 09:29, Sebastian Huber wrote: On 06.05.24 09:08, Richard Biener wrote: On Sat, 4 May 2024, Sebastian Huber wrote: On 07.08.23 16:22, Qing Zhao via

Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? thanks. Qing Begin forwarded message: From: Qing Zhao Subject: Re

Re: Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 10:02, Qing Zhao wrote: 2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? For convenience, the

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
wrote: > > On 06.05.24 16:20, Qing Zhao wrote: >> Hi, Sebastian, >> Looks like that the behavior you described is correct. >> What’s your major concern? ( a little confused). > > I am concerned that the static initialization of structures with flexible > array members no

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 13:57, Sebastian Huber wrote: On 07.05.24 16:26, Qing Zhao wrote: Hi, Sebastian, Thanks for your explanation. Our goal is to deprecate the GCC extension on structure containing a flexible array member not at the end of another structure. In order to achieve this goal, we

<    1   2   3   4   5   6   7   8   9   10   >