www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14560] New: Strange -inline behavior

https://issues.dlang.org/show_bug.cgi?id=14560

          Issue ID: 14560
           Summary: Strange -inline behavior
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: chalucha gmail.com

I had a problem with vibe.d which I've dustmited to code below.
Problem is that whet I use -inline switch (used by dub with -b release),
program fails. Without it it is ok. GDC and LDC2 works ok.

I don't understand what is happening here, but I guess the problem can be with
serialize function overrides with different results? But then why it runs ok
with foreach removed in serializeImpl?

import std.traits;

struct JsonStringSerializer
{
    void getSerializedResult() { }
}

void serializeToJson(T)(T value)
{
    serialize!(JsonStringSerializer)(value);
}

auto serialize(Serializer, T)(T value)
{
    auto serializer = Serializer();
    serialize(serializer, value);
    return serializer.getSerializedResult;
}

void serialize(Serializer, T)(Serializer serializer, T value)
{
    serializeImpl!(Serializer, T)(serializer, value);
}

void serializeImpl(Serializer, T)(Serializer , T value)
{
    foreach (i; value) { }
}

int main()
{
    serializeToJson(["test"]);
    return 0;
}

--
May 08 2015