Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 30, 2006 [Issue 622] New: There should be a warning for unininitalized class reference | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=622 Summary: There should be a warning for unininitalized class reference Product: D Version: 0.175 Platform: PC OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: andkhropov@mtu-net.ru This error is very common for people with C++ background (I've already seen people asking questions about similar code several times): ---------------------------------------------- class Foo{ public int data; } void main() { Foo f; // obviously they try do this way as they got used to it in C++ // should be a warning here! f.data = 1;// Access violation } ---------------------------------------------- -- |
December 01, 2006 [Issue 622] There should be a warning for unininitalized class reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=622 wbaxter@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wbaxter@gmail.com ------- Comment #1 from wbaxter@gmail.com 2006-11-30 18:16 ------- Yes please! I make this mistake all the time, and every time it takes a few minutes tracking down why and where my program is crashing. -- |
December 01, 2006 Re: [Issue 622] New: There should be a warning for unininitalized class reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com escribió: > http://d.puremagic.com/issues/show_bug.cgi?id=622 > > Summary: There should be a warning for unininitalized class > reference > Product: D > Version: 0.175 > Platform: PC > OS/Version: Windows > Status: NEW > Severity: enhancement > Priority: P2 > Component: DMD > AssignedTo: bugzilla@digitalmars.com > ReportedBy: andkhropov@mtu-net.ru > > > This error is very common for people with C++ background (I've already seen > people asking questions about similar code several times): > ---------------------------------------------- > class Foo{ > public int data; > } > > void main() > { > Foo f; // obviously they try do this way as they got used to it in C++ > // should be a warning here! > > f.data = 1;// Access violation > } > > ---------------------------------------------- > > Actually, the warning should be in "f.data = 1;". You are trying to access a member of an uninitialized variable. Take a look at this code: ---------------------------------------------- Foo f; if (something) { f = new Foo(); } else { f = new Bar(); } f.data = 1; ---------------------------------------------- (where Bar extends Foo, for example). No warning should be generated, everyhing in it's place. That's the way access to uninitialized variable in java works. They are errors, not just warnings (the program will crash there, no matter what happens). |
April 12, 2010 [Issue 622] There should be a warning for unininitalized class reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=622 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #3 from bearophile_hugs@eml.cc 2010-04-12 12:00:02 PDT --- This bug is half-fixed: the compiler is now able to catch this bug at compile-time, but only if the code is compiled with -O. I think the compiler has to catch this bug when not optimized mode is used too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 26, 2010 [Issue 622] There should be a warning for unininitalized class reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=622 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |bugzilla@digitalmars.com -- 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