On 31/07/14 07:51, Jared Maddox wrote:
>> Date: Tue, 29 Jul 2014 19:11:24 +0800
>> From: "YX Hao" <[email protected]>
>> To: <[email protected]>
>> Subject: [Tinycc-devel] How to optimize compiling sizeof const?
>> Message-ID: <1BB4CCF1522243D28E17C6C418FDB416@HYXPC>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi there,
>>
>> We know that tcc generates bigger binary file than gcc for non-small
>> projects. But I'm not meaning the optimization options.
>>
>> Here I find the titled issue when I compile an html5 library (Google's
>> "gumbo"). In the compiled object file and linked binary file, that of tcc
>> you can find the string to be calculated size of is stored, and you will see
>> it will not be used with a debugger, while gcc generates clean file with
>> smaller size. The attached file is a piece of code for testing.
>>
> 
> Just to be certain that I'm understanding correctly, you're talking
> about something like this:
> 
> size_t size_size()
> {
>   return( sizeof( "sizeof" ) );
> }
> void arg_size( void (*func)( const char* ) )
> {
>   if( func )
>   {
>     ( *func )( "sizeof" );
>   }
> }
> 
> And the behavior in question is that TWO copies of "sizeof" are
> included in the resulting object file, correct? This is specifically a

I thought the OP was complaining that the expression:

    sizeof("a string literal")

was causing an _unused_ copy of the string literal to be stored in
the data section. This expression is a compile-time constant and,
once it has been evaluated, the string literal is no longer required
(even at compile time).

However, I may have misunderstood. :-D

ATB,
Ramsay Jones



_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to