Can this mostly useless while loop be optimized out?

K

Keith Thompson

Flash Gordon said:
It is just as possible in C.


<snip>

Search for "null pointer 0x55555555" without the quotes and you will
find someone who actually has an implementation where the null pointer
is not all bits zero. Others may exist either now on in the
future. You just have to decide whether it is worth the effort of
catering for such systems. If you cater for them, then do it properly,
if you don't cater for them properly then you don't need either
compile or run time checks to provide partial/broken support for them.

Another reasonable option is to do a run-time check during program
startup, and abort the program with an error message if a null pointer
is not all-bits-zero. You could check just one type, or you could
check, say, void*, int*, and struct foo*. If your program wouldn't
have run properly on an exotic system anyway, it might as well not
pretend to do so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top