Re: [PATCH v3] c++: designated init of char array by string constant [PR55227]

2022-01-17 Thread will wray via Gcc-patches
Attached (the cut n paste looks like it removed some whitespace formatting) 0001-c-designated-init-of-char-array-by-string-constant-P.patch Description: Binary data

[PATCH v3] c++: designated init of char array by string constant [PR55227]

2022-01-17 Thread will wray via Gcc-patches
V3 addresses Jason's review point - it.undoes unnecessary variable renames (back from arr_init to str_init) Also address "FIXME: this code is duplicated from reshape_init" in cp_complete_array_type by always calling reshape_init on init-list. PR c++/55227 gcc/cp/ChangeLog: * decl.c

Re: [PATCH 3/3] c++: P1997 array-copy extensions: Assignment, return, etc. [PR103238]

2021-11-22 Thread will wray via Gcc-patches
On Mon, Nov 22, 2021 at 3:42 PM Joseph Myers wrote: > > On Sun, 21 Nov 2021, Will Wray via Gcc-patches wrote: > > > gcc/c/ChangeLog: > > > > * c-decl.c (grokdeclarator): Don't complain of array returns. > > A C front-end change like this doesn't belong

Re: [PATCH] c++: __builtin_bit_cast To C array target type [PR103140]

2021-11-22 Thread will wray via Gcc-patches
any standardization effort. > > The semantics of bit_cast is clear - it's just the resulting rvalue array > itself is unfamiliar and tricky to handle within current language rules. > > On Mon, Nov 15, 2021 at 12:21 PM Jakub Jelinek wrote: > > > > On Mon, Nov 15, 202

[PATCH 3/3] c++: P1997 array-copy extensions: Assignment, return, etc. [PR103238]

2021-11-21 Thread Will Wray via Gcc-patches
This second patch completes the work of the first 'array-copy' patch to provide first-cut implementations of all P1997 features. It adds: * Assignments to arrays from array values,a = b; * Placeholder auto in array declarations, auto cp[] = a; * Array as a return type from functions

[PATCH 2/3] c++: P1997 array-copy extensions: Initialization [PR103238]

2021-11-21 Thread Will Wray via Gcc-patches
This patch implements initializations of arrays from array values. The first of two 'array-copy' patches, it adds the option -farray-copy (flag_array_copy) to enable all features of P1997 (copy related or not), documented as experimental extensions. It deals with initialization of array

[PATCH 1/3] c++: designated init of char array by string constant [PR55227]

2021-11-21 Thread Will Wray via Gcc-patches
Also address "FIXME: this code is duplicated from reshape_init" in cp_complete_array_type by always calling reshape_init on init-list. PR c++/55227 gcc/cp/ChangeLog: * decl.c (reshape_init_r): Only call has_designator_check when first_initializer_p or for the inner

[PATCH 0/3] P1997 'array-copy' patchset [PR103238]

2021-11-21 Thread Will Wray via Gcc-patches
([PATCH 1/3] already submitted fix for PR c++/55227, is a dependency here.) These patches implement C++ proposal P1997 "Relaxing restrictions on array" that adds: C array copy semantics: * array-array initializations * array-array assignments * array return-by-value from functions

Re: [PATCH] c++: designated init of char array by string constant [PR55227]

2021-11-18 Thread will wray via Gcc-patches
V2 Patch mailing list post https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584897.html On Thu, Nov 18, 2021 at 10:36 AM Marek Polacek wrote: > > On Wed, Nov 17, 2021 at 10:23:58PM -0500, will wray wrote: > > V2 Patch > > https://gcc.gnu.org/bugzilla/attachment.cgi?id=51828 > > Can you

[PATCH v2] c++: designated init of char array by string constant [PR55227]

2021-11-18 Thread Will Wray via Gcc-patches
Also address "FIXME: this code is duplicated from reshape_init" in cp_complete_array_type by always calling reshape_init on init-list. PR c++/55227 gcc/cp/ChangeLog: * decl.c (reshape_init_r): Only call has_designator_check when first_initializer_p or for the inner

Re: [PATCH] c++: designated init of char array by string constant [PR55227]

2021-11-17 Thread will wray via Gcc-patches
V2 Patch https://gcc.gnu.org/bugzilla/attachment.cgi?id=51828 On Wed, Nov 17, 2021 at 10:06 PM will wray wrote: > > Thanks for the review Marek; > I'll post the updated patch in a follow-on message and on bugzilla. > > On Mon, Nov 15, 2021 at 8:03 PM Marek Polacek wrote: > > > I also noticed

Re: [PATCH] c++: designated init of char array by string constant [PR55227]

2021-11-17 Thread will wray via Gcc-patches
Thanks for the review Marek; I'll post the updated patch in a follow-on message and on bugzilla. On Mon, Nov 15, 2021 at 8:03 PM Marek Polacek wrote: > I also noticed the C++ FE rejects > > struct A { char x[4]; }; > struct B { struct A a; }; > struct B b = { .a.x = "abc" }; > but the C

Re: [PATCH] c++: __builtin_bit_cast To C array target type [PR103140]

2021-11-15 Thread will wray via Gcc-patches
at 12:21 PM Jakub Jelinek wrote: > > On Mon, Nov 15, 2021 at 12:12:22PM -0500, will wray via Gcc-patches wrote: > > One motivation for allowing builtin bit_cast to builtin array is that > > it enables direct bitwise constexpr comparisons via memcmp: > > > >

PING: [PATCH] c++: designated init of char array by string constant [PR55227]

2021-11-15 Thread will wray via Gcc-patches
The fixes test out, as does the FIXME that's fixed based on the fixes... Note that the bug causes bogus rejection of any designated initialization of char array from a string literal, except for the singular case where the string literal initializer size exactly matches the target char array size

Re: [PATCH] c++: __builtin_bit_cast To C array target type [PR103140]

2021-11-15 Thread will wray via Gcc-patches
Ping. One motivation for allowing builtin bit_cast to builtin array is that it enables direct bitwise constexpr comparisons via memcmp: template constexpr int bit_equal(A const& a, B const& b) { static_assert( sizeof a == sizeof b, "bit_equal(a,b) requires same

[PATCH] c++: __builtin_bit_cast To C array target type [PR103140]

2021-11-08 Thread Will Wray via Gcc-patches
This patch allows __builtin_bit_cast to materialize a C array as its To type. It was developed as part of an implementation of P1997, array copy-semantics, but is independent, so makes sense to submit, review and merge ahead of it. gcc/cp/ChangeLog: * constexpr.c (check_bit_cast_type):

[PATCH] c++: designated init of char array by string constant [PR55227]

2021-11-06 Thread Will Wray via Gcc-patches
This patch aims to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55227. There are two underlying bugs in the designated initialization of char array fields by string literals that cause: (1) Rejection of valid cases with: (a) brace-enclosed string literal initializer (of any valid size), or

[PATCH] c++ PR 55227: designated init of char array by string constant

2021-11-04 Thread will wray via Gcc-patches
This patch aims to fix PR 55227; two underlying bugs that have caused: (1) Rejection of valid designated initialization of char array fields by string literals (a) when enclosed in optional braces or (b) unbraced when the string literal is shorter than the target char array field. (2) Acceptance