Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

SUM() not accepted in constant expression

$
0
0

Hello,

the following code appears to be valid, but ifort rejects it:

program ifort_sum_param
  implicit none
  real, parameter :: a(3) = [ 1., 2., 3. ]
  real, parameter :: b = sum (a)
  print *, b
end

I get:

% ifort -V ifort-sum.f90
Intel(R) Fortran Compiler XE for applications running on IA-32, Version 15.0.3.187 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

 Intel(R) Fortran 15.0-1812
ifort-sum.f90(4): error #6263: This intrinsic function is invalid in constant expressions.   [SUM]
  real, parameter :: b = sum (a)
-------------------------^
compilation aborted for ifort-sum.f90 (code 1)

As far as I can tell, and by looking at the F2008 standard, section 7.1.12 (constant expression), there is no exclusion for SUM() to be used here.

The above code is accepted by the GNU and Cray compilers.

 


Viewing all articles
Browse latest Browse all 3108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>