www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15272] New: [2.069-rc2, inline] nothing written to output when

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

          Issue ID: 15272
           Summary: [2.069-rc2,inline] nothing written to output when
                    -inline is set
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bb.temp gmx.com

Created attachment 1560
  --> https://issues.dlang.org/attachment.cgi?id=1560&action=edit
involed project

I have this project that compiles fine with 2.069-rc2 but doesn't work anymore.
So far I didn't manage to reduce the issue because several factors are mixed:

What happens now:
=================

nothing is written to stdout.

what should happens:
====================

stdout filled.

when does this work anyway:
===========================

1/ if I use the 'new' operator instead of my custom 'construct' template.
2/ if I disable the inline switch.
3/ if I create a File with "w" flag before writing stdout.

with the 3rd workaround being totally WTF. So maybe something in File __ctor
fix the issue ?!.

code:
=====

see attachment

shell commands:
===============

dmd
/home/basile/Dev/pasproj/Coedit/cesyms/cesyms.d
/home/basile/Dev/metad/libs/libdparse.a
-I/home/basile/Dev/metad/repos/libdparse/src
-w
-inline
-O
-release
-boundscheck=off
-of../lazproj/cesyms


Attempt to reduce:
==================

So far I'm here but it doesn't capture the essence of the problem.

---
//#!runnable-flags: -O -inline
module runnable;

import core.memory;
import std.stdio, std.array, std.conv;
import std.experimental.allocator.mallocator;

ST* construct(ST, Allocator = Mallocator, A...)(A a)
if(is(ST==struct))
{
    auto memory = Allocator.instance.allocate(ST.sizeof)[0 .. ST.sizeof];
    //GC.addRange(memory.ptr, ST.sizeof);
    return emplace!(ST, A)(memory, a);
}

struct Foo
{
    Foo*[] children;    
    void get(ref Appender!string app)
    {
        app.put("whatever");
        foreach(child; children) child.get(app);
    }
}

void main(string[] args)
{
    Appender!string app;
    Foo* foo = construct!Foo;
    foreach(i; 0..100) 
    { 
        foo.children ~= construct!Foo;
        foreach(j; 0..100) foo.children[i].children ~= construct!Foo;     
    }
    foo.get(app);
    auto s = app.data;
    assert(0, s);
}
Nov 01 2015