[C PATCH] Evaluate argument of sizeof that are structs of variable size.

Joseph Myers joseph@codesourcery.com
Tue Aug 10 17:19:43 GMT 2021

On Mon, 9 Aug 2021, Uecker, Martin wrote:

> I am still trying to figure out what the branch guarded
> by c_vla_type_p is for in c_expr_sizeof_type. The comment
> talks about [*], but how would you apply sizeof to
> such an array?  One can form something like

The comment describes a requirement on what happens for [*], but that 
branch in the code isn't restricted to cases involving [*]; it covers any 
case where (the type is a VLA and) groktypename has returned an expression 
to be evaluated before the type name.

E.g. take your vla-stexp-1.c test but with sizeof(typeof(...)) instead of 
sizeof(...) - that aborts, but I'd hope such a fix in c_expr_sizeof_type 
would make it pass.

Joseph S. Myers

More information about the Gcc-patches mailing list