R
rahul
#include <stdio.h>
int
main (void) {
char *p = NULL;
printf ("%c\n", *p);
return 0;
}
This snippet prints 0(compiled with DJGPP on Win XP). Visual C++ 6.0
compiles the program with diagnostics and the program crashes when
ran. gcc on Linux gives SEGMENTATION FAULT.
This looks like a bug with DJGPP. NULL can have different
representations but how come the compiler allows de-referencing NULL
without any compile time or run-time errors?
P.S : I am not discussing DJGPP. I just want to know if this behaviour
is OK with C specs?
int
main (void) {
char *p = NULL;
printf ("%c\n", *p);
return 0;
}
This snippet prints 0(compiled with DJGPP on Win XP). Visual C++ 6.0
compiles the program with diagnostics and the program crashes when
ran. gcc on Linux gives SEGMENTATION FAULT.
This looks like a bug with DJGPP. NULL can have different
representations but how come the compiler allows de-referencing NULL
without any compile time or run-time errors?
P.S : I am not discussing DJGPP. I just want to know if this behaviour
is OK with C specs?