[Issue 18284] Can call struct method through a null pointer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 23 07:04:41 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18284
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |simen.kjaras at gmail.com
Resolution|--- |INVALID
--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Try it again with print() being final on the class. The reason your code causes
a runtime error with the class is the method is virtual, and so needs to be
looked up in the vtable. No such lookup is necessary for the struct, and so no
null-deref happens, and so no runtime error.
--
More information about the Digitalmars-d-bugs
mailing list