Thread overview |
---|
April 11, 2007 [Issue 1123] New: We can change Struct.init | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1123 Summary: We can change Struct.init Product: D Version: unspecified Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: s180m@yahoo.co.jp struct Matrix { double e = 1.; Matrix scale(double r){e*=r;return *this;} const Matrix Identity = {10.}; } void main(){ for(int i;i<5;i++){ printf("%f\n",Matrix.Identity.scale(.9).e); } printf("\n"); for(int i;i<5;i++){ printf("%f\n",Matrix.init.scale(.9).e); } } ----------------- 9.000000 8.100000 7.290000 6.561000 5.904900 0.900000 0.810000 0.729000 0.656100 0.590490 -- |
April 25, 2007 [Issue 1123] We can change Struct.init | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1123 thomas-dloop@kuehne.cn changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|We can change Struct.init |We can change Struct.init ------- Comment #1 from thomas-dloop@kuehne.cn 2007-04-25 12:58 ------- That is again a case where the compiler didn't put unchangeable content (Identitiy and init) readonly section but read-write section. On Linux "init" is in a readonly section and thus the second loop segfaults. It would be nice if the compiler enforced/checked read-write rights. -- |
January 30, 2012 [Issue 1123] We can change Struct.init | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1123 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Platform|x86 |All Resolution| |WORKSFORME OS/Version|Windows |All --- Comment #2 from yebblies <yebblies@gmail.com> 2012-01-30 14:32:41 EST --- Currently both D1 and D2 (1.068 & 2.058) compilers print: 9.000000 9.000000 9.000000 9.000000 9.000000 0.900000 0.900000 0.900000 0.900000 0.900000 As .init creates a temporary this is correct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation