tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] missing check after calling type_size in classify_x86


From: Pascal Cuoq
Subject: Re: [Tinycc-devel] missing check after calling type_size in classify_x86_64_arg
Date: Sun, 23 Jun 2019 22:43:19 +0000

Hello,

> On 23 Jun 2019, at 23:18, Michael Matz <address@hidden> wrote:
> 
> The patch definitely goes into the right direction, though it seem more 
> verbose than necessary.  I'd just test for functions or incomplete types (via 
> type_size), and then you have the opportunity to retain the more precise 
> error message for the former, ala
> 
>  if (func)
>    tcc_error ...
>  else if (type_size < 0)
>    tcc_error ...
>  okay ...

I considered this but:
- the single generic error message seemed consistent with a compiler which 
advertises its small size and its speed, and which was accepting these programs 
until recently,
- but even producing a generic error message, functions would have to remain as 
a separate case because type_size returns 1 for them,
- and also type_size returns 1 for void, so that would have to be another 
separate case if we wish to reject arrays of void.

Two separate cases mean we have to compute type->t & VT_BTYPE. If we call 
type_size it will recompute it, and store an alignment that we do not require 
to a variable that we will have to declare. It doesn't look like it's shorter 
or faster.

If you think that this much code should be put in a function, that might be 
useful elsewhere, I can do that, but when compiling GCC's dialect of C where 
pointer arithmetic is legal for pointers to void and function pointers, “being 
a type with a size in the sense of pointer arithmetic” and “being a complete 
type” become different enough to require two different functions.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]