Another compile-time perversion. Or not?

Don Clugston dac at nospam.com.au
Fri Sep 1 00:15:16 PDT 2006


Walter Bright wrote:
> Don Clugston wrote:
>> Walter Bright wrote:
>>> Ivan Senji wrote:
>>>> Actually dmd produces one more line:
>>>> Internal error: ..\ztc\cgobj.c 395
>>>> but that isn't a part of the fractal.
>>>
>>> That is caused by the compiler writing all the const values out to 
>>> the object file, and overflowing the counters in the object module 
>>> format because there are so many. Unfortunately, it isn't fixable, 
>>> it's an artifact of the format.
>>>
>>> The slowness is also caused by the generation of stupendous object 
>>> files.
>>
>> Why do all of the const values need to be written to object file? I 
>> would expect that once a template has been constant folded, it should 
>> be possible to discard that reference to it. If it is not used 
>> elsewhere, it shouldn't need to be included at all.
> 
> There's a bit of chicken and egg problem with it - can't tell if it's 
> referenced or not until code generation, which is intimately wrapped up 
> with object file generation.

But isn't it true that a template consisting only of
'const' and 'static if' will *never* result in code generation? After it 
has been constant folded, it will always be safe to discard it.

That might not cover all of the theoretically discardable templates, but 
it would give almost all of the practical benefits.



More information about the Digitalmars-d-announce mailing list