Pages

Tuesday, February 03, 2009

Null Pointer on AIX

Have a look at this code.

#include

int main() {
int *a = 0;
int b = *a;

printf("hello world\n");
return 0;
}

What will the output be. Will it ever get to say hello ? In most worlds other than IBM's, it won't.
But AIX has its own idiosyncracies. So the qualified answer is, "it depends"

Here is what a very old text I found had to say (This was from AIX 3.2 times)

   9.1.  Derefencing NULL Pointers



The word at memory location zero contains a zero.

That means that code which has been incorrectly

written to use a NULL pointer to represent a null

string will work, but will not be portable to all

UNIX operating systems, and may not work on future

AIX systems.

So that explains it. On AIX, at least till version 5.3, you can
dereference a null pointer, and get away with it :)


Here is the link to the original document , for more such trivia. Would post more of these later, need to get back to work.

http://www.rootunix.org/AIX/325bsdpo.txt

Fine Print: This is a repost. I have now decided to use thruput as my only blog, giving up on http://360.yahoo.com/mqzaidi/blog. You would see some old content resurrected from that blog here.