Multiple issues with Sun Studio Express December 2006 Build
At comp.lang.fortran, Bob Corbett asked to report issues with SSX3 in this forum. Here we go:
The code example below triggers three (3) different errors in sunf95, but not with Intel, GNU or Lahey compilers.
a) Compile as-is. The result should be 1.0 but the binary crashes with a segmentation fault. The reason: it seems that array x is not passed correctly from SD to MEAN (implied by the array size in mean which is unequal 3).
$> sunf95 -g -w3 -ansi ssx3.f90 && ./a.out
size in sd: 3
size in mean: 1073741824
Segmentation fault
b) Uncomment the USE statement in line 11. Intel and GNU compilers report, that it's not possible to USE a module while compiling it, sunf95 reports an ICE.
$> sunf95 -g -w3 -ansi ssx3.f90
"sunf95.f90", Line = 25, Column = 1: INTERNAL: Interrupt: Segmentation fault
c) Uncomment the interface declaration from line 14-19. Intel, GNU and sunf95 compile this alike, all three report an undefined reference to mean_, but with sunf95 there is also a dwarf error:
$> sunf95 -g -w3 -ansi ssx3.f90
/usr/bin/ld: Dwarf Error: mangled line number section.
sunf95.o: In function `math.sd_':
sunf95.f90:(.text+0x1bc): undefined reference to `mean_'
Regards
Daniel
The code:
$> cat ssx3.f90
MODULE math
CONTAINS
FUNCTION mean(x)
REAL, DIMENSION(:), INTENT(in) :: x
REAL:: mean
WRITE(*,*)"size in mean:", size(x)
mean = sum(x)/size(x)
END FUNCTION
FUNCTION sd(x)
!USE math, ONLY: mean ! uncommentfor ICE
! uncommentfor"/usr/bin/ld: Dwarf Error: mangled line number section."
!INTERFACE
!FUNCTION mean(x)
! REAL, DIMENSION(:), INTENT(in) :: x
! REAL:: mean
!END FUNCTION
!END INTERFACE
REAL, DIMENSION(:), INTENT(in) :: x
REAL:: sd
WRITE(*,*)"size in sd:", size(x)
sd = SQRT(SUM((x - mean(x))**2) / DBLE(size(x) - 1))
END FUNCTION
END MODULE
PROGRAM test_sd
USE math
REAL, DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
WRITE(*,*) sd(x)
END PROGRAM

