digitalmars.D.bugs - [Issue 7169] New: [CTFE] Assertion failure with inner struct
- d-bugmail puremagic.com (32/32) Dec 27 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7169
- d-bugmail puremagic.com (42/42) Jan 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7169
- d-bugmail puremagic.com (9/30) Oct 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7169
- d-bugmail puremagic.com (17/30) Oct 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7169
http://d.puremagic.com/issues/show_bug.cgi?id=7169 Summary: [CTFE] Assertion failure with inner struct Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: youxkei gmail.com --- struct Struct(T){ T t; } void func(T)(T t){ Struct!T s; s.t = t; } static assert({ struct InnerStruct{ void func(){} } func(InnerStruct()); return true; }()); void main(){} This code doesn't work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7169 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-invalid-code CC| |clugdbug yahoo.com.au According to the spec, I don't think this is supposed to work. expression.html says: ---- Nested structs cannot be used as fields or as the element type of an array: void foo() { int i = 7; struct SS { int x,y; int bar() { return x + i + 1; } } struct DD { SS s; // error, cannot be field } } ---- So creating such a struct by passing the nested struct as a template parameter shouldn't work either. But, the compiler accepts the examples that the spec says are errors. So I'm not sure if the bug is in the spec or the compiler. The ICE is a variation of bug 6419, but where the nested struct is part of a struct literal. Here's a test case with the same ICE, but this time where it's part of an array. void func2(T)(T t){ T[2] s; s[0] = t; } static assert({ struct InnerStruct{ void func(){} } func2(InnerStruct()); return true; }()); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7169 22:53:15 PDT ---struct Struct(T){ T t; } void func(T)(T t){ Struct!T s; s.t = t; } static assert({ struct InnerStruct{ void func(){} } func(InnerStruct()); return true; }()); void main(){} This code doesn't work.It produces a correct error message: test.d(6): Error: delegate test.__lambda4 is a nested function and cannot be accessed from test.func!(InnerStruct).func -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7169 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 22:55:34 PDT ---According to the spec, I don't think this is supposed to work.It's not.void func2(T)(T t){ T[2] s; s[0] = t; } static assert({ struct InnerStruct{ void func(){} } func2(InnerStruct()); return true; }());This also produces a correct error message: test.d(2): Error: cannot access frame pointer of test.__lambda3.InnerStruct test.d(10): Error: template instance test.func2!(InnerStruct) error instantiating Not an ICE. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 05 2013