D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7106 - DMD Segmentation faults!
Summary: DMD Segmentation faults!
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-14 01:25 UTC by Caligo
Modified: 2012-01-02 00:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Caligo 2011-12-14 01:25:54 UTC
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
Comment 1 Kenji Hara 2012-01-02 00:50:51 UTC
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.