(non)nullable types
Brian
digitalmars at brianguertin.com
Mon Feb 9 10:39:10 PST 2009
On Mon, 09 Feb 2009 18:20:56 +0000, Brian wrote:
> well, at the very least id like to see a (optional) warning/error for
> uninitialized pointers. This way I can be certain there are absolutely
> zero null pointers unless the null keyword itself is used. A quick
> search for 'null' would be guaranteed to show all possibly null
> variables. I know I'm not the first to wish for such. (Does a warning
> exist yet that I don't know about?)
just to clarify, this is what id like. given this code:
void main() {
Foo f;
bar(null);
}
class Foo() {}
void bar(Foo) {}
$ dmd main.d
Completed Successfully
$ dmd -wnull main.d
main.d(2): warning: variable 'f' is default initialized to null
main.d(3): warning: passing null as argument to function expecting Foo
To prevent the warnings, you would need to change main to this:
void main() {
Foo f = null;
bar(cast(Foo)null);
}
More information about the Digitalmars-d
mailing list