www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14453] New: segfault in release mode

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

          Issue ID: 14453
           Summary: segfault in release mode
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ellery-newcomer utulsa.edu

the following code segfaults at runtime with dmd 2.067 (apparently 2.066 also)
when compiled like so:

dmd -release -O multi_index.d

but not when compiled like so:

dmd multi_index.d


multi_index.d:

import std.traits;

struct Item {
    uint id;
    long time;
}

void main() {
    alias Container = MultiIndexContainer!(Item);

    Container c = new Container();
    c.index0.insert( Item(21, 35), );
}

template OrderedIndex() {
    alias void* Node;
    alias const(Item) Elem;
    auto _add(Node n) { }

    size_t insert(Stuff)(Stuff ) if (isImplicitlyConvertible!(Stuff, Elem)) {
        Node n ;
        _add(n);
        return 1;
    }
}

class MultiIndexContainer(Value) {
    this(){
    }
    new(size_t sz) {
        return new void[](sz).ptr;
    }

    mixin OrderedIndex!() index0;
}

--
Apr 16 2015