Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 14, 2012 [Issue 8238] New: regression: templates can create ghost fields | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8238 Summary: regression: templates can create ghost fields Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: regression Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: timon.gehr@gmx.ch --- Comment #0 from timon.gehr@gmx.ch 2012-06-14 07:36:12 PDT --- DMD 2.059: struct S{ template t(){ int t; } } void main(){ S s,t; writeln(t.t!()); // 0 s.t!()=256; writeln(t.t!()," ",s.t!()); // 1 256 } The code is illegal, but accepted. I remember that such code used to be rejected. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 18, 2012 [Issue 8238] regression: templates can create ghost fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8238 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|accepts-invalid |wrong-code Severity|regression |major --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-18 09:11:32 PDT --- The code is not illegal, but generates wrong code. See "Limitations" in http://dlang.org/template . > Templates cannot be used to add non-static members or virtual functions to classes. For example: > > class Foo { > template TBar(T) { > T xx; // becomes a static member of Foo > int func(T) { ... } // non-virtual > > static T yy; // Ok > static int func(T t, int y) { ... } // Ok > } > } In this case, variable t in template t should become static member of struct S. Therefore following test case should pass, but fails with assertions. extern(C) int printf(const char*, ...); struct S{ template t(){ int t; } } void main(){ S s1, s2; printf("%p %p\n", &s1, &s1.t!()); printf("%p %p\n", &s2, &s2.t!()); assert(cast(void*)&s1 != cast(void*)&s2 ); assert(cast(void*)&s1 != cast(void*)&s1.t!()); // fails assert(cast(void*)&s2 != cast(void*)&s2.t!()); // fails assert(cast(void*)&s1.t!() == cast(void*)&s2.t!()); // fails s1.t!() = 256; assert(s2.t!() == 256); // fails } I couldn't find the dmd version "used to be rejected". But for the above reasons, This is not a regression, but just a wrong-code bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 18, 2012 [Issue 8238] templates can create ghost fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8238 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-18 09:14:46 PDT --- https://github.com/D-Programming-Language/dmd/pull/1054 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 19, 2013 [Issue 8238] templates can create ghost fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8238 --- Comment #3 from github-bugzilla@puremagic.com 2013-02-18 18:46:43 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b7f3f45b62541099bbff5e263a4da6f2b00c9023 fix Issue 8238 - templates can create ghost fields https://github.com/D-Programming-Language/dmd/commit/c20f46ca30b3a9ec8f4c3ab4e76397b0e691926f Merge pull request #1054 from 9rnsr/fix8238 Issue 8238 - templates can create ghost fields -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 19, 2013 [Issue 8238] templates can create ghost fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8238 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- 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