public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* Flexible array member
@ 2021-12-10 17:44 Marc Nieper-Wißkirchen
  2021-12-10 21:00 ` David Malcolm
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Nieper-Wißkirchen @ 2021-12-10 17:44 UTC (permalink / raw)
  To: jit

C99 (and thus GCC) allow defining structures that end in a flexible array
member ([1]).

How can this be encoded in libgccjit? Is it valid to create an array type
of length 0 and use that to define the last field in a struct?

Thanks,

Marc

--

[1] https://en.wikipedia.org/wiki/Flexible_array_member

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Flexible array member
  2021-12-10 17:44 Flexible array member Marc Nieper-Wißkirchen
@ 2021-12-10 21:00 ` David Malcolm
  0 siblings, 0 replies; 2+ messages in thread
From: David Malcolm @ 2021-12-10 21:00 UTC (permalink / raw)
  To: Marc Nieper-Wißkirchen, jit

On Fri, 2021-12-10 at 18:44 +0100, Marc Nieper-Wißkirchen via Jit
wrote:
> C99 (and thus GCC) allow defining structures that end in a flexible
> array
> member ([1]).
> 
> How can this be encoded in libgccjit? Is it valid to create an array
> type
> of length 0 and use that to define the last field in a struct?

I don't know.

I did some quick grepping of the C front-end, and gcc/c/c-decl.c's
grokdeclarator has:

		/* ISO C99 Flexible array members are effectively
		   identical to GCC's zero-length array extension.  */
		if (flexible_array_member || array_parm_vla_unspec_p)
		  itype = build_range_type (sizetype, size_zero_node,
					    NULL_TREE);

So using length 0 for the array type might work in libgccjit, or it
might not, as there might be something else in the IR that libgccjit
needs to set up for it to work properly.  You could try it, I guess.

Sorry not to have a clearer answer.
Dave



> 
> Thanks,
> 
> Marc
> 
> --
> 
> [1] https://en.wikipedia.org/wiki/Flexible_array_member
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-10 21:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 17:44 Flexible array member Marc Nieper-Wißkirchen
2021-12-10 21:00 ` David Malcolm

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).