public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers
@ 2014-11-19 0:31 jsm28 at gcc dot gnu.org
2014-11-19 0:42 ` [Bug c/63944] " joseph at codesourcery dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-11-19 0:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944
Bug ID: 63944
Summary: [DR#413] Partial overriding of nonconstant
struct/union initializers with designated initializers
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
C11 DR#413 has now moved to closed (see N1892). This says that if an
initializer (a) initializes a struct or union member of a larger object using
an expression of that struct or union type and (b) then uses a designated
initializer to override just part of that struct or union initialization, then
the overriding does not affect the initialization of the rest of the struct or
union. Thus, the following should pass (based on the test in the DR):
extern void exit (int);
extern void abort (void);
typedef struct {
int k;
int l;
int a[2];
} T;
typedef struct {
int i;
T t;
} S;
T x = {.l = 43, .k = 42, .a[1] = 19, .a[0] = 18 };
int
main (void)
{
S l = { 1, .t = x, .t.l = 41, .t.a[1] = 17};
if (l.t.k == 42) exit (0); else abort ();
}
Clearly the existing approach for string constants (of splitting them
individual characters) won't work here (but is still needed for initializers of
objects with static storage duration). This bug is specific to initializers of
objects with automatic storage duration; it can apply both to initialization
with an expression of struct type, and to initialization with one of union type
(in the union case, the override would have to be of just part of a union
member, as setting the whole of a union member sets the whole union). I
suppose some initializations with such partial overriding need to generate more
complicated code - one possibility might be for such partial overriding to
replace the initializer for .t with (tmp = x, tmp.l = 41, tmp) for a new
temporary variable tmp.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/63944] [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers
2014-11-19 0:31 [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers jsm28 at gcc dot gnu.org
@ 2014-11-19 0:42 ` joseph at codesourcery dot com
2014-11-19 9:06 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: joseph at codesourcery dot com @ 2014-11-19 0:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Actually, I suppose the existing approach for strings could be used if
desired - split the struct into a series of component references to a
SAVE_EXPR of the nonconstant struct initializer (in the case of a union,
the partially overriding initializer would say which union element needs
splitting like that). Whether that's desirable is another matter (say the
struct being partially overridden is struct S { int a[1000000]; } -
splitting into separate initializers would mean 1000000 SAVE_EXPRs, which
seems unlikely to work well).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/63944] [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers
2014-11-19 0:31 [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers jsm28 at gcc dot gnu.org
2014-11-19 0:42 ` [Bug c/63944] " joseph at codesourcery dot com
@ 2014-11-19 9:06 ` jakub at gcc dot gnu.org
2020-03-19 21:00 ` [Bug c/63944] [DR413] " jsm28 at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-19 9:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-11-19
Ever confirmed|0 |1
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'm afraid I don't remember anything from my designated initializers changes,
it was too long time ago, so if anybody else (Joseph, Marek, anyone else?)
wants to implement this, go ahead ;).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/63944] [DR413] Partial overriding of nonconstant struct/union initializers with designated initializers
2014-11-19 0:31 [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers jsm28 at gcc dot gnu.org
2014-11-19 0:42 ` [Bug c/63944] " joseph at codesourcery dot com
2014-11-19 9:06 ` jakub at gcc dot gnu.org
@ 2020-03-19 21:00 ` jsm28 at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2020-03-19 21:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944
Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dje at gcc dot gnu.org
--- Comment #9 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
*** Bug 94225 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/63944] [DR413] Partial overriding of nonconstant struct/union initializers with designated initializers
2014-11-19 0:31 [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers jsm28 at gcc dot gnu.org
` (2 preceding siblings ...)
2020-03-19 21:00 ` [Bug c/63944] [DR413] " jsm28 at gcc dot gnu.org
@ 2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-05 16:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63944
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|mpolacek at gcc dot gnu.org |unassigned at gcc dot gnu.org
Status|ASSIGNED |NEW
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-05 16:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-19 0:31 [Bug c/63944] New: [DR#413] Partial overriding of nonconstant struct/union initializers with designated initializers jsm28 at gcc dot gnu.org
2014-11-19 0:42 ` [Bug c/63944] " joseph at codesourcery dot com
2014-11-19 9:06 ` jakub at gcc dot gnu.org
2020-03-19 21:00 ` [Bug c/63944] [DR413] " jsm28 at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
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).