digitalmars.D.learn - dmd segfaults
- matovitch (22/22) May 31 2014 Hi !
- bearophile (15/17) May 31 2014 Please report this minimized case to Bugzilla:
- matovitch (4/22) May 31 2014 Thanks ! I should have minimized it. Anyway I discovered I had
- matovitch (15/15) May 31 2014 In fact it segfauls on any template parameter if it has the same
- matovitch (2/2) May 31 2014 I remembered my psswd don't take my last sentence into account (i
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (5/20) May 31 2014 It doesn't even need a template, this crashes too:
- matovitch (3/3) May 31 2014 I updated the issue. Strangely if done in the main everything is
- H. S. Teoh via Digitalmars-d-learn (8/12) May 31 2014 [...]
Hi ! Does anybody knows why dmd segfaults on this code ? Should I report this as a bug ? import std.stdio; enum LiftingGender { PREDICT, UPDATE, } struct Test(float[][] coeffs, int[] offsets, LiftingGender gender) { immutable float[][] coeffs = coeffs; immutable int[] offsets = offsets; immutable LiftingGender gender; } void main() { Test!([[0.5,-1]], [-1], LiftingGender.PREDICT) test; writeln(test); }
May 31 2014
matovitch:Does anybody knows why dmd segfaults on this code ? Should I report this as a bug ?Please report this minimized case to Bugzilla: struct Foo(int[] arr) { const int[] arr = arr; } void main() { Foo!([0]) foo; } The error it gives before the crash: test.d(2,17): Deprecation: variable test.Foo!([0]).Foo.arr const field with initializer should be static, __gshared, or an enum The cause of the crash if that the local variable has the same name as the template argument, combined with the reported error. Bye, bearophile
May 31 2014
On Saturday, 31 May 2014 at 17:01:23 UTC, bearophile wrote:matovitch:Thanks ! I should have minimized it. Anyway I discovered I had already a bugzilla account unfortunately I can't remember my password and the email takes his time... :-(Does anybody knows why dmd segfaults on this code ? Should I report this as a bug ?Please report this minimized case to Bugzilla: struct Foo(int[] arr) { const int[] arr = arr; } void main() { Foo!([0]) foo; } The error it gives before the crash: test.d(2,17): Deprecation: variable test.Foo!([0]).Foo.arr const field with initializer should be static, __gshared, or an enum The cause of the crash if that the local variable has the same name as the template argument, combined with the reported error. Bye, bearophile
May 31 2014
In fact it segfauls on any template parameter if it has the same name as the immutable member (at least it's coherent). Something as simple as : struct Foo(int i) { immutable int i = i; } void main() { Foo!5 foo; writeln(foo); } I am suprised that nobody tried this before. BTW I am starting to worry : my mail didn't arrived yet. I would be very grateful if someone could report this for me. :S
May 31 2014
I remembered my psswd don't take my last sentence into account (i will filed this).
May 31 2014
On Saturday, 31 May 2014 at 17:22:41 UTC, matovitch wrote:In fact it segfauls on any template parameter if it has the same name as the immutable member (at least it's coherent). Something as simple as : struct Foo(int i) { immutable int i = i; } void main() { Foo!5 foo; writeln(foo); } I am suprised that nobody tried this before. BTW I am starting to worry : my mail didn't arrived yet. I would be very grateful if someone could report this for me. :SIt doesn't even need a template, this crashes too: struct Test { immutable float[] i = i; }
May 31 2014
I updated the issue. Strangely if done in the main everything is fine : Error: undefined identifier i
May 31 2014
On Sat, May 31, 2014 at 04:50:11PM +0000, matovitch via Digitalmars-d-learn wrote:Hi ! Does anybody knows why dmd segfaults on this code ? Should I report this as a bug ?[...] Compiler segfaults should always be reported. No matter how wrong the code may be, it is never right for the compiler to crash -- it should reject the code and terminate normally. T -- Never ascribe to malice that which is adequately explained by incompetence. -- Napoleon Bonaparte
May 31 2014