Template specialized functions creating runtime instructions?
Patrick.Schluter at bbox.fr
Wed Aug 21 10:01:48 UTC 2019
On Wednesday, 21 August 2019 at 00:11:23 UTC, ads wrote:
> On Wednesday, 21 August 2019 at 00:04:37 UTC, H. S. Teoh wrote:
>> On Tue, Aug 20, 2019 at 11:48:04PM +0000, ads via
>> Digitalmars-d-learn wrote: [...]
>> 2) Deducing the string as you describe would require CTFE
>> (compile-time function evaluation), which usually isn't done
>> unless the result is *required* at compile-time. The typical
>> way to force this to happen is to store the result into an
>> enum myStr = fizzbuzz!...(...);
>> Since enums have to be known at compile-time, this forces CTFE
>> evaluation of fizzbuzz, which is probably what you're looking
>> for here.
> Thank you for clearing those up. However even if I force CTFE
> (line 35), it doesn't seem to help much.
on line 4113 you have that string
and all main() does is call writeln with that string
lea rsi, [rip + .L.str]
mov edi, 203
call @safe void
xor eax, eax
You haven't given instruction to the linker to strip unused code
so the functions generated by the templates are still there.
More information about the Digitalmars-d-learn