Please do us a favor and add the correct NULL
checks to your code. Not only will you have a small performance gain by checking NULL
only when necessary, rather than having the compiler check everywhere, but your code will be more portable for other platforms.
And we will not mention that you are more likely to print the correct error message, instead of having the compiler delete some obscure code / dump of the source code / source code, which will not help your users at all.
AIX uses the concept of a NULL page. Essentially, NULL
(i.e., Virtual Address 0x0
) maps to a location containing a whole bunch of zeros. This allows you to use the string manipulation code etc to continue, even though a NULL
pointer is encountered.
This is contrary to most other Unix-like systems, but it does not violate the C standard, which considers dereferencing NULL a undefined. In my opinion, this is terribly violated: this requires an application that breaks sharply and turns it into one that silently ignores programming errors, which can lead to completely incorrect results.
As far as I know, GCC is not able to work with fundamentally broken code. Even historically supported patterns, such as writable string literals, have been phased out in newer versions of GCC.
There may be some support when using memory debugging options such as -fmudflap
, but I really don't know - in any case, you should not use debugging code on production systems, especially to make corrupted code work.
Bottom line: I don't think you can avoid adding explicit NULL
checks.
Unfortunately, now we move on to the main question: where should NULL checks be added ?. I believe that the compiler will add such checks indiscriminately, it will help if you add an explicit check when you find a problem.
Unfortunately, there is no Valgrind support for AIX. If you have money, you can take a look at IBM Rational Purify Plus for AIX - this can cause such errors.
You can also use xlc
in the test system and gcc
for everything else, but, unfortunately, they are not fully compatible.
thkala
source share