D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7439 - Compound assignment causes segmentation fault
Summary: Compound assignment causes segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: yebblies
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2012-02-04 14:47 UTC by Caligo
Modified: 2015-06-09 05:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Caligo 2012-02-04 14:47:00 UTC
Tested on Gnu/Linux, 64-bit, DMD-2.057

--------------------------8<----------------------------8<--------------------------------------

struct A(int r, int c){

public:
  alias r R;
  alias c C;
  alias float[R * C] Data;
  Data _data;
  alias _data this;

  this(Data ar){ _data = ar; }

  pure ref float opIndex(size_t rr, size_t cc){ return _data[cc + rr * C]; }
}

void main(){

  A!(2, 2) a = A!(2, 2)([8, 3, 2, 9]);
  a[0,0] -= a[0,0] * 2.0;
}

-------------------------->8---------------------------->8--------------------------------------

workaround: avoid compound assignment operators.
Comment 2 yebblies 2012-02-19 23:57:26 UTC
Fixed D2:
https://github.com/D-Programming-Language/dmd/commit/34cb3dec9de6c1c01850447c29fc2bc81d386382

Can't reproduce with D1.