Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28453 Discussions

Inquiry function warnings for -stand flag

andreasskeidsvoll
1,819 Views

Hi,

The following minimal example

program main

  use, intrinsic :: iso_c_binding, only : c_sizeof

  implicit none

  integer :: int_bit_size = bit_size(1)
  integer :: int_sizeof = sizeof(1)

  integer :: int_storage_size = storage_size(1)
  integer :: int_c_sizeof = int(c_sizeof(1))

  print *, int_bit_size, int_sizeof
  print *, int_storage_size, int_c_sizeof

end program main

 gives the following warnings during compilation

main.F90(10): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [STORAGE_SIZE]
  integer :: int_storage_size = storage_size(1)
--------------------------------^
main.F90(11): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [C_SIZEOF]
  integer :: int_c_sizeof = int(c_sizeof(1))
--------------------------------^

when compiled with all combinations of ifx and ifort and the flags -stand f90 -stand f95, -stand f03, -stand f08 and -stand f18. It does not give any warnings when compiled without the -stand flags.

I have had a look at the Fortran 2018 standard, and cannot see why storage_size and c_sizeof should give warnings and not bit_size. The compilers also do not give warnings for sizeof, even though it's not part of the standard. Is there something wrong with these warning messages, or am I missing something?

1 Solution
Ron_Green
Moderator
1,697 Views

Agreed with Steve and FortranFan.  I see the bogus warning in our nightly builds as well.  We'll open a bug report.

View solution in original post

0 Kudos
19 Replies
FortranFan
Honored Contributor II
1,797 Views

Correction: see the comment below:

 

TL;DR:

  • Use `C_SIZE_OF` intrinsic in executable section of the code, not in initialization expression such as "integer :: int_c_sizeof = int(c_sizeof(1))"
  • Use `C_SIZE_OF` with named objects, not literal constants.  This is because the argument X to this function has to be an interoperable entity and thus it cannot be a constant such as '1'.

Try this out and see if you would avoid the warnings with it:

 

 

   use, intrinsic :: iso_c_binding, only : c_sizeof, c_int, c_size_t
   integer(c_int), parameter :: x = 1_c_int
   integer(c_size_t) :: int_c_sizeof
   int_c_sizeof = c_sizeof(x)
   print *, "int_c_sizeof  = ", int_c_sizeof
end

 

 

 

 

 

0 Kudos
andreasskeidsvoll
1,791 Views

Thank you for the response. You are right that using c_sizeof in an executable part of the code removes the warning. I would, however, like to define the integer byte size as a parameter that is reused in several parts of the code, without having to calculate it with a function each time.  You are probably also right that the c_sizeof warning might be because the argument is not a variable, although I still have to understand what it means for an entity to be interoperable.

Do you know why the warning for the storage_size function appears? There does not seem to be a requirement for interoperability in the standard, but does constants fall outside the definition of a data object? From 16.9.184 STORAGE_SIZE (A [, KIND]) in J3/18-007r1:

 

Arguments:
A    shall be a data object of any type. If it is polymorphic it shall not be an undefined pointer. If
     it is unlimited polymorphic or has any deferred type parameters, it shall not be an unallocated
     allocatable variable or a disassociated or undefined pointer.

 

 

0 Kudos
FortranFan
Honored Contributor II
1,771 Views

@andreasskeidsvoll ,

Re: "I would, however, like to define the integer byte size as a parameter that is reused in several parts of the code, without having to calculate it with a function each time." - 

  • after reviewing the PDF toward the standard again on my kid's iPad in between travel points just now, apologies - I take back what I wrote earlier (I will scratch my earlier comment, I wrote too soon).  Both `C_SIZEOF` and `STORAGE_SIZE` are permitted under specification inquiry in constant expressions provided each primary is a constant expression.  So I reckon the standard permits the following (note untested) which may be what you seek:
       use, intrinsic :: iso_c_binding, only : c_sizeof, c_size_t, c_int
       integer(c_size_t), parameter :: bits_c_int = c_sizeof(1_c_int)
       integer(c_size_t), parameter :: bits_default_integer = storage_size(1, kind=c_size_t)
    end
    ​

What version of Intel Fortran are you using?  Have you tried the latest, 2023.0.0 IFX?

 

0 Kudos
andreasskeidsvoll
1,745 Views

@FortranFan I'm using the 2023.0.0 ifx and 2021.8 ifort. I tried to follow your suggestion by changing the code to

 

program main

  use, intrinsic :: iso_c_binding, only : c_sizeof, c_size_t, c_int

  implicit none

  integer(c_size_t), parameter :: bits_c_int = c_sizeof(1_c_int)
  integer(c_size_t), parameter :: bits_default_integer = storage_size(1, kind=c_size_t)

  print *, bits_c_int, bits_default_integer

end program main

 

but compilation still gives the warnings

 

main.F90(7): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [C_SIZEOF]
  integer(c_size_t), parameter :: bits_c_int = c_sizeof(1_c_int)
-----------------------------------------------^
main.F90(8): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [STORAGE_SIZE]
  integer(c_size_t), parameter :: bits_default_integer = storage_size(1, kind=c_size_t)
---------------------------------------------------------^

 

As an additional point, I would like to use the integer bit/byte size to keep track of how much memory is used by integers in the Fortran part of the code. I would also prefer to use the default Fortran integer bit size determined by the compiler/compiler flags, without setting the integer kind in the code.

0 Kudos
andrew_4619
Honored Contributor II
1,761 Views

The original code  compiles with no errors or warning using  "Intel® Fortran Compiler Classic 2021.7.0 [Intel(R) 64]"

What version are you using? I remember filing a bug report on "intrinsic function in an initialization expression" a long time ago but those got fixed.

0 Kudos
andreasskeidsvoll
1,746 Views

@andrew_4619 Interesting – I'm using ifort 2021.8.0 and ifx 2023.0.0.

0 Kudos
Steve_Lionel
Honored Contributor III
1,716 Views

The compiler is incorrect in issuing these warnings - I agree with @FortranFan 's explanation above.

 

0 Kudos
Ron_Green
Moderator
1,698 Views

Agreed with Steve and FortranFan.  I see the bogus warning in our nightly builds as well.  We'll open a bug report.

0 Kudos
Ron_Green
Moderator
1,667 Views

Bug ID is CMPLRLLVM-43356


0 Kudos
Steve_Lionel
Honored Contributor III
1,352 Views

From the Fortran Discourse forum, the following code gives errors (not just standards warnings), where again the usage is a specification inquiry.

use,intrinsic:: ieee_arithmetic, only: ieee_support_standard
print *, [ ieee_support_standard(1e0), ieee_support_standard(1d0) ]
end program

0 Kudos
Barbara_P_Intel
Moderator
1,269 Views

Thanks, @Steve_Lionel, love these short reproducers. Seems like a real constant should be acceptable. I filed a bug on this, CMPLRLLVM-43725. 

0 Kudos
Steve_Lionel
Honored Contributor III
1,265 Views

@Barbara_P_Intel , the problem isn't the constant, but the reference to the "specification inquiry" function - ieee_support_standard in my last post. These are allowed in constant expressions, but what qualifies as a specification inquiry isn't spelled out in the constant expression text but rather in the previous subsection on specification expressions. 

0 Kudos
Barbara_P_Intel
Moderator
1,262 Views

@Steve_Lionel Thank you for the clarification! I learn a lot from reading this Forum.

0 Kudos
JohnNichols
Valued Contributor III
1,149 Views

@Barbara_P_Intel , I just read this post.  It made me smile and my mind wandered. 

Question 1, read in this sense should be red as that is how it is pronounced. 

Question 2: I fixed a Format statement a minute ago, took me a minute to work out the dumb typing mistake, another smile. 


    DO   1589   I=1,NJOIN
        WRITE(*,56)JNN(I),FXX(I),FYY(I),FMM(I)
56      FORMAT(20X,I10,3(10X,3F10.3))
1589 CONTINUE

Jim:  I will fix the continue, there is only one of me.  

Question 3: Learning, the place not to learn is in a 65 foot yacht off the New South Wales coast in a blow, about 65 knots and the waves are about 30 feet high and you are on the foredeck, it is 2am, you are changing headsails, wire halyard in one hand, shackle in the other and the guy with you who is holding the head of the sail says, "I dropped the shackle key overboard".  You realize it is Easter and you forgive him, because you never do the shackles up more than hand tight.  

 

0 Kudos
Barbara_P_Intel
Moderator
1,151 Views

The 2 bug reports that Ron and I filed for issues on this thread are fixed in the compiler that was released this week as part of oneAPI HPC Toolkit 2023.1.

Please check it out!



andreasskeidsvoll
1,100 Views

@Barbara_P_Intel Unfortunately, the minimal example I gave in the original post still gives the following warnings during compilation

 

 

$ ifx -c main.F90 -stand f18
main.F90(10): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [STORAGE_SIZE]
  integer :: int_storage_size = storage_size(1)
--------------------------------^
main.F90(11): warning #7347: This intrinsic function in an initialization expression is not standard Fortran 2018   [C_SIZEOF]
  integer :: int_c_sizeof = int(c_sizeof(1))
--------------------------------^

 

 

when compiled with both

 

 

$ ifx -v
ifx version 2023.1.0

 

 

and

 

$ ifort -v
ifort version 2021.9.0

 

 

The warning is also present for the adapted code in this post.

0 Kudos
Barbara_P_Intel
Moderator
1,034 Views

So sorry, my bad. It will be fixed in the next release planned for this summer, i.e. summer in the northern hemisphere, winter elsewhere.

 

 

0 Kudos
JohnNichols
Valued Contributor III
1,023 Views

The equator is like the if statement that can take, -1, 0 and 1, summer and winter only occur on the ones that have an absolute value of 1, the equator has neither seasons and water does not swirl in the toilet bowl.  

I realize it is a thin strip of the world, but a lot of people live there. 

 

0 Kudos
Barbara_P_Intel
Moderator
760 Views

Both bugs that were filed on this Forum thread are fixed in the compiler that was released last week as part of oneAPI HPC Toolkit 2023.2.

Please try it out!



0 Kudos
Reply