LAPACK/BLAS from FORTRAN on 10.6
since updating to 10.6, I've been struggling with strange crashes in connection with LAPACK/BLAS routines used in my C++ code, when using the Apple LAPACK and BLAS. They are strange in this sense, that I get a "Bus error" in a reproducible fashion, however depending on whether optimization was. Further, even adding an innocent statement such as cout << "Hi" may prevent the crashes - which probably means that there is some subtle memory corruption issue. Up to now, it's hard for me to tell if it's my own fault, or Apple's, but the same code runs fine under a variety of Linux machines. (Desperately waiting for valgrind on 10.6 ...)
Anyway, during my search I finally found a reproducible problem (not susceptible to optimization). Consider the following Fortran code:
COMPLEX*16 A(1), B(1),C
C=ZDOTC( 1, A, 1, B, 1 )
WRITE (*,*) C
(It is essentially just a complicated way of calculating A(1)*B(1))
If I compile this with gfortran (4.5 from hpc.sourceforge.net) or g95 (current version from www.g95.org) and link against the Apple BLAS (-lblas), I always get a Bus error (gfortran) or segfault (g95) at C=ZDOTC ...
Note that this does not happen if I use the manually compiled version of BLAS from netlib.org.
I was wondering if anybody else could reproduce this problem, just to make sure that I didn't overlook something simple ...