jfr@tel3.tel.vtt.fi (Jim Reilly) (11/10/89)
Should there be a warning generated if you declare an instance of an object, and accidentally forget to identify it (assuming 'new' isn't used to allocate the space) ? Our ATT1.2 cfront/Glockenspiel compiler didn't complain about something like this: class Flying { ... // structors Flying (Llist* llist) { ... llist->add(this); } ~Flying () { // remove 'this' from llist ... } }; main () { Llist llist_head; Flying (&llist_head); // ^ no identifier, should be: Flying flying(&llist_head); // object has no scope ? .... // unidentified object disappears .... } The unidentified Flying object (sorry, I couldn't resist the pun :-) seemed to linger in the llist for a while, but eventually would disappear (I assume it has no scope) from the llist. In my case, after the object was declared (and the constructor put it into the llist), the llist took care of everything else that needed to be done with the object (using the pointer to the object), so i never had to do anything explicit like : flying.my_stuff(). The bug in my code was easy to find, but if it is easy to put a warning into cfront (or wherever), it might be useful to have: "stuff.cxx", 14: warning: unidentified object: class Flying I realize this might not be so easy to do, and the case described may be uncommon, so this is just a suggestion. Hopefully ATT2.0 already generates such a warning, or an error. jim -- Internet Mailbox: reilly@tel.vtt.fi UUCP Mailbox: ...!arpa!router.funet.fi!vtttel!reilly ...!mcvax!kth!draken!tut!router!vtttel!reilly