Bus Error

The bus in question is the address buss and it contains an illegal value. This is almost always the result of dereferencing a pointer that contains an illegal value.

Here is a program that, I think, will compile with every C or C++ compiler, but should cause a bus error when the second printf is attempted...

#ifdef __STDC__
#define PROTOTYPICAL
#endif
#ifdef __cplusplus
#define PROTOTYPICAL
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef PROTOTYPICAL
int main(int argc, char *argv[])
#else
main(argc,argv)
char *argv[];
#endif
{
      double d = 1.23456789;
      double *p = &d;
      printf ( " d = %f \n" , *p);
      p = (double *)((char *)p + 1);
      printf ( " d = %f \n" , *p);
      exit(0);
}