DMD producing huge binaries
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 23 11:54:32 PDT 2016
On 5/19/16 6:17 PM, Walter Bright wrote:
> On 5/19/2016 8:39 AM, Steven Schveighoffer wrote:
>>> template(T) foo if (someConstraints)
>>> {
>>> struct Result
>>> {
>>> T t;
>>> }
>>>
>>> auto foo(T t)
>>> {
>>> return Result(t);
>>> }
>>> }
>>
>> This solution works awesomely, actually. It even produces smaller code
>> than
>> moving the struct completely outside.
>>
>> I'm going to use this mechanism in iopipe to get my voldemorts back :)
>
>
> Consider using a 'static struct'. A non-static struct will include a
> hidden member that points to the stack frame of foo(), i.e. "produces
> smaller code".
Yes, I did use static in my actual code. In fact, I found a bug because
of this (one of my voldemort functions was allocating a closure because
I had thought I was using a member but was actually using a function
parameter).
But this doesn't fix the symbol size problem. The other mechanism does.
-Steve
More information about the Digitalmars-d
mailing list