Patch for Quad.cc compile error on Sun/GCC
John W. Eaton
jwe at octave.org
Tue May 5 10:28:55 CDT 2009
On 5-May-2009, Carsten Clark wrote:
| 2009/5/4 John W. Eaton <jwe at octave.org>:
| >
| > I checked in the change, but what about
| >
| > quad (@(x) x, single (0), single (2))
| >
| > ? Are you using the Sun Fortran compiler? My guess is that it will
| > work, and that GCC and the Sun Fortran compiler will handle floats in
| > a compatible way, unlike for doubles.
|
| I was using g77 from GCC 4. This works:
|
| $ octave -qf
| octave:1> quad ( @(x) x, 0, 2 )
| ans = 2
| octave:2> quad ( @(x) x, single(0), single(2) )
| ans = 2.0000
|
| I rebuilt using g++4 and this Sun Studio Fortran compiler:
|
| $ /opt/SunStudioExpress/bin/f77 -V
| NOTICE: Invoking /opt/SunStudioExpress/bin/f90 -f77 -ftrap=%none -V
| f90: Sun Ceres Fortran 95 8.3 SunOS_i386 2008/10/22
|
| and that works, too (your guess is right!):
|
| octave:1> quad ( @(x) x, 0, 2 )
| ans = 2
| octave:2> quad ( @(x) x, single(0), single(2) )
| ans = 2
|
| Actually, the GCC manual
| (http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Interoperation.html)
| states that the compatibility problem that access_double() solves only
| occurs on SPARC systems. I'm on an Intel PC. Changing the #ifdefs in
| Quad.cc and sun-utils.h to __sparc, as in the attached patch, I can
| still run the above test code successfully, with both g77 and Sun
| Studio f77. (I verified that __sparc is not defined for me and the
| access_double() lines are not compiled.)
|
| I've checked a SPARC system at work, and it does define __sparc and
| sparc. The Sun Studio 12 User's Guide
| (http://docs.sun.com/app/docs/doc/819-5267/6n7c46edt) also lists these
| symbols as defined on SPARC only. However, I don't have GCC 4 on that
| system, so probably can't try building Octave.
|
| At any rate, access_double() and assign_double() aren't necessary on
| my system, and it looks like this should be true of Solaris/Intel
| systems in general, unless I'm a fluke for some reason.
I applied the patch.
In the future, can you submit Mercurial changesets instead of plain
context diffs?
Thanks,
jwe
More information about the Bug-octave
mailing list