![]() |
|
|
|
|
|
|
6
9th November 23:01
External User
Posts: 1
|
sam_cit@yahoo.co.in writes:
In what context, and what exactly do you mean by "give an error"? Pointer objects can be initialized to NULL, initialized to some other value, or uninitialized. I don't think there's any context in which a compiler is required to issue a diagnostic for an uninitialized or null pointer. A decent compiler might issue a non-fatal warning on an attempt to *use* a null or uninitialized pointer. Show us an example, and we can tell you (a) what a compiler is required to do, and (b) what a compiler is allowed to do. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. |
|
|
7
9th November 23:06
External User
Posts: 1
|
CBFalconer said:
<cough> I beg to differ. I can see why you might find reasons not to initialise, but to say there is *no* reason to initialise is a bit strong, isn't it? And that's a great reason for initialising pointers to NULL if you have no better value for them - so that you can find out whether you can legally dereference them by inspecting their value. -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk email: rjh at the above domain, - www. |
|
|
9
9th November 23:07
External User
Posts: 1
|
Harald van D?k said:
<snip> Yes, but for me they are the exception rather than the rule. Sure, but what's to stop Joe Maintainer from slipping in a deref by mistake, halfway between declaration and first assignment? I'd rather make his debugging job a bit easier by giving him a null pointer to detect. <snip> -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk email: rjh at the above domain, - www. |
|