www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13690] New: Curiously Recurring Template Pattern causes

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

          Issue ID: 13690
           Summary: Curiously Recurring Template Pattern causes segfault.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: pdj9 pitt.edu

The following causes dmd to segfault:

import std.traits;

interface BarBase
{
    void do_a_thing();
}

interface Bar(T) : BarBase
{
    static if(hasMember!(T, "rotation") && is(typeof(T.rotation) == 
double))
{
          property
     double rotation();

    final void do_a_thing()
        {
                //do a thing with rotation;
    }
}
else
{
    final void do_a_thing()
    {
            //do a thing without rotation;
    }
}
}

class Foo1 : Bar!Foo1
{
}

class Foo2 : Bar!Foo2
{
     property
    double rotation() { return 1.0; };
}

This code is theoretically compilable because if it were changed to imitate the
halting problem then: if the function is declared final then there isn't a
conflict, if it isn't then the class has to be abstract.

--
Nov 05 2014