views:

471

answers:

2

The following Fortran code is giving me a bus error on my Mac but no errors when I run it on my Linux machine:

  PROGRAM TINY
  WRITE(UNIT=*, FMT=*) 'Hello, world!'
  END

My understanding is that a bus error occurs when the program attempts to access impossible memory but I do not understand where such an attempt has been made in this program. My MacBook has GCC 4.4.0 and my Linux machine has GCC 4.3.2. Any ideas as to why this error occurs?

A: 

Hi

No ideas at all, just thought I'd let you know that I have no problems compiling and running the program on my Mac Pro. I compiled with G95 (GCC 4.0.4 (g95 0.91!) Dec 11 2008). Like you, I think a bus error is usually an attempt to address memory which doesn't exist.

Regards

Mark

High Performance Mark
bus error means trying to write to program memory
JoelFan
"bus error" is caused by an access to a physically illegal address -- see http://en.wikipedia.org/wiki/Bus_error. In contrast, a "segmentation fault" is typically caused by accessing an address that exists, but which the program is not allowed to access -- see http://en.wikipedia.org/wiki/Segmentation_fault. Trying to write to program memory would more likely cause a segmentation fault. It depends on the operating system, etc.
M. S. B.
oops, sorry... should I delete my comment?
JoelFan
No, leave it there as a potent reminder to all of us on SO that we can all learn from the hive mind and all are better for it :-)
High Performance Mark
A: 

The program runs fine on my Mac with gfortran 4.4.2. Do other Fortran programs run on your MacBook, or do they all have this problem?

M. S. B.