Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 03, 2009 [Issue 2929] New: Alias this when this is null | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2929 Summary: Alias this when this is null Product: D Version: 2.029 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: jason.james.house@gmail.com The code below should demonstrate the problem. The implicit use of alias this is not null-aware. That means that a nullable class reference with alias this to another reference type is used, then segfaults will occur. The only workaround is to define an intermediate variable and test for null before relying on the implicit alias to work. This kind of kills the utility of alias this. class A{} class B{ private A a; A foo(){ return a; } alias foo this; } void main(){ B b; A a = b; // seg fault assert(a is null); } -- |
February 14, 2012 [Issue 2929] Alias this when this is null | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2929 Lukasz Wrzosek <luk.wrzosek@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |luk.wrzosek@gmail.com Resolution| |DUPLICATE --- Comment #1 from Lukasz Wrzosek <luk.wrzosek@gmail.com> 2012-02-14 14:31:59 PST --- *** This issue has been marked as a duplicate of issue 6777 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 14, 2012 [Issue 2929] Alias this when this is null | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2929 Lukasz Wrzosek <luk.wrzosek@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|DUPLICATE | --- Comment #2 from Lukasz Wrzosek <luk.wrzosek@gmail.com> 2012-02-14 14:34:36 PST --- Sorry, it is not a duplicate ... :( -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 05, 2013 [Issue 2929] Alias this when this is null | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2929 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |INVALID --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-04 18:17:14 PST --- I don't understand this report. alias won't protect you from null references, keeping references non-null is the programmer's responsibility. -- 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