|
From: | Michael Matz |
Subject: | Re: [Tinycc-devel] missing check after calling type_size in classify_x86_64_arg |
Date: | Sat, 22 Jun 2019 21:16:08 +0200 (CEST) |
User-agent: | Alpine 2.21 (LSU 202 2017-01-01) |
Hello, On Sat, 22 Jun 2019, Pascal Cuoq wrote:
That is a big can of worm you have pointed me to.
Historically TCC hasn't cared much about invalid input, so yeah, there be dragons :)
Here is another part of the code that seems wrong and continues to seem wrong even with the suggested change:
... struct_layout excerpt ...
align starts its life as an automatic, uninitialized variable. At each iteration, the call to type_size sets it unless the call fails and leaves align's previous value in it. My only change so far in this function is the comment “call type_size here, because t->type can be incomplete if it is a flexible array member”: I stand by this comment, because calling ctype_size here makes TCC abort while compiling pcctest.c.
Sure, at this point you can't require a complete type (for the reasons you state).
For a flexible array member of a complete element type, this currently works out fine : size_type stores the element type's alignment even if the array is a FAM.
Yeah, that's the idea.
struct s { char a; enum e b[]; } s; struct t { int a[3]; void b[]; } t; typedef void u; struct v { int a[3]; u b[]; } v; struct w { int a[3]; struct n b[]; } w;
The thing to realize about all these invalid examples is, that it's not the struct decl which is wrong, i.e. you don't need to change anything within struct_decl or struct_layout. It's already the array declarator itself which is wrong: an array declarator requires a complete element type.
So, what you want to change is post_type (which cares for array and function declarators, given a base type) so that the incoming type is complete if necessary.
Ciao, Michael.
[Prev in Thread] | Current Thread | [Next in Thread] |