C++17 cannot beat D surely

rikki cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 4 03:39:09 PDT 2017


On 04/06/2017 11:27 AM, Vittorio Romeo wrote:
> On Sunday, 4 June 2017 at 10:21:16 UTC, rikki cattermole wrote:
>> On 04/06/2017 11:06 AM, Vittorio Romeo wrote:
>>> Could someone clarify why the generated assembly for
>>>
>>> void main() @nogc {
>>>      import std.algorithm;
>>>      enum a = [3, 1, 2, 0]; // inferred to be int[]
>>>      enum b = sort(a);
>>>      static assert(b[0] == 0);
>>> }
>>>
>>> is 1380 lines with ldc 1.3.0 (-O3 -release -betterC -flto=full)?
>>> You can see the result on godbolt here:
>>> https://godbolt.org/g/BNRnO9
>>>
>>> It's kind of surprising compared to C++'s 2 lines:
>>> https://godbolt.org/g/vXrxaY
>>
>> _Dmain is exactly 2 instructions, so nope equivalent :)
>> The linker isn't stripping out unused symbols however (from what I can 
>> tell).
> 
> I see. Is there any argument that can be passed to ldc in order to strip 
> the unused symbols?

Should be a way, since you can pass arg directly via ldc to ld. But I 
would expect it to have done it by default anyway.


More information about the Digitalmars-d mailing list