Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 27, 2011 [Issue 7169] New: [CTFE] Assertion failure with inner struct | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Hisayuki Mima <youxkei@gmail.com> 2011-12-27 18:29:01 JST --- 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: ------- |
January 01, 2012 [Issue 7169] [CTFE] Assertion failure with inner struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hisayuki Mima | 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 --- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-01-01 11:43:28 PST --- 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: ------- |
October 06, 2013 [Issue 7169] [CTFE] Assertion failure with inner struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hisayuki Mima | http://d.puremagic.com/issues/show_bug.cgi?id=7169 --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2013-10-05 22:53:15 PDT --- (In reply to comment #0) > 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: ------- |
October 06, 2013 [Issue 7169] [CTFE] Assertion failure with inner struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hisayuki Mima | http://d.puremagic.com/issues/show_bug.cgi?id=7169 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2013-10-05 22:55:34 PDT --- (In reply to comment #1) > 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: ------- |
Copyright © 1999-2021 by the D Language Foundation