www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7106] New: DMD Segmentation faults!

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7106

           Summary: DMD Segmentation faults!
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: iteronvexor gmail.com



struct Ma(T){

  pure T alpha() const{ return 1.1; }
  Ma opBinary(string op)(in Ma m) const if(op == "-"){ return Ma(m); }
}

struct Pa(T){

  Ma!T _m;
  alias _m this;
}

pure T foo(alias P, T)(in P!T p){ return (p - p).alpha(); }


void main(){

  Pa!double p1;
  foo(p1);
}


This is as far as I could narrow it down.  Something starts to go wrong when
'opBinary' is called.  Also, removing pure from 'foo' doesn't cause the seg
fault.

DMD 2.56, Linux-64bit

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 14 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7106


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME



In 2.057 and later, following errors are raised:

test.d(17): Error: incompatible types for ((p) - (p)): 'const(Pa!(double))' and
'const(Pa!(double))'
test.d(22): Error: template instance test.foo!(Pa,double) error instantiating

Because, in Ma!T.opBinary(),

  return Ma(m);

is not valid expression (it does not ignite copy construction).
After fixing it to

  return Ma();

, the sample code compiles fine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012