public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109863] New: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x
@ 2023-05-15 16:29 yann at droneaud dot fr
2023-05-16 2:43 ` [Bug c/109863] " xry111 at gcc dot gnu.org
2023-05-16 2:44 ` xry111 at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: yann at droneaud dot fr @ 2023-05-15 16:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109863
Bug ID: 109863
Summary: RFE: more consistent flex array initialization: lift
static storage requirement in gnu2x
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: yann at droneaud dot fr
Target Milestone: ---
I've noted some discrepancies in the flex array initialization support:
/* https://godbolt.org/z/9er5G9G15 */
struct s { char i; char c[]; };
extern void t(const struct s*);
void f(void)
{
// ERROR: non-static initialization of a flexible array member
const struct s c0 = { .c = "0", };
t(&c0);
// ERROR: non-static initialization of a flexible array member
const struct s *const c1 = &(const struct s) { .c = "1", };
t(c1);
// OK
const struct s *const c2 = &(constexpr struct s) { .c = "2", };
t(c2);
// ERROR: initializer element is not constant
static const struct s *const c3 = &(constexpr struct s) { .c = "3", };
t(c3);
// OK
static const struct s *const c4 = &(static constexpr struct s) { .c =
"4", };
t(c4);
}
AFAICT constexpr is not supposed to also mean static storage at the block
level, so flex array in c2 is initialized in a non-static way ...
Then I would be happy if GCC could be enhanced to not reject c0 and c1
initialization.
But I fear the opposite will happen, and GCC will reject c2 initialization too
:)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/109863] RFE: more consistent flex array initialization: lift static storage requirement in gnu2x
2023-05-15 16:29 [Bug c/109863] New: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x yann at droneaud dot fr
@ 2023-05-16 2:43 ` xry111 at gcc dot gnu.org
2023-05-16 2:44 ` xry111 at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-05-16 2:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109863
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Note that the entire "initializing a flexible array member" thing is a GNU
extension and not supported by the standard. So GCC is free to support the
constexpr case but reject other non-static cases.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/109863] RFE: more consistent flex array initialization: lift static storage requirement in gnu2x
2023-05-15 16:29 [Bug c/109863] New: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x yann at droneaud dot fr
2023-05-16 2:43 ` [Bug c/109863] " xry111 at gcc dot gnu.org
@ 2023-05-16 2:44 ` xry111 at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-05-16 2:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109863
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #1)
> Note that the entire "initializing a flexible array member" thing is a GNU
> extension and not supported by the standard. So GCC is free to support the
> constexpr case but reject other non-static cases.
Or, "it's an extension after all, so it's not related to if the standard say
constexpr implies static or not".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-16 2:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15 16:29 [Bug c/109863] New: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x yann at droneaud dot fr
2023-05-16 2:43 ` [Bug c/109863] " xry111 at gcc dot gnu.org
2023-05-16 2:44 ` xry111 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).