- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have to comment out the INTRINSIC statement in the code below with ifort/ifx, but not with gfortran/nvfortran. Should the INTRINSIC statement be allowed?
module M_overload
! allow SIGN(3f) to take a single argument
use, intrinsic :: iso_fortran_env, only : int32
implicit none
private
public :: sign
!intrinsic :: sign ! ifort 2023 bug(?)
interface sign ; module procedure sign_int32; end interface
contains
elemental function sign_int32(value)
integer(kind=int32),intent(in) :: value
integer(kind=int32) :: sign_int32
sign_int32=sign(1_int32,value)
end function sign_int32
end module M_overload
program tryit
use M_overload, only : sign
implicit none
write(*,*) merge('sign works','sign fails', sign(10).eq.1 .and. sign(-10).eq.-1 )
end program tryit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good news! I ran this with the coming release of ifort 2021.9.0 and ifx 2023.1.0 and it compiles and runs!
$ ifx --version
ifx (IFX) 2023.1.0 20230216
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
$ ifx tryit.f90
$ a.out
sign works
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The message I get with ifx 2023 and ifort 2023 is
xx.f90(23): error #6505: This intrinsic procedure reference contains too few arguments. [SIGN]
write(*,*) merge('sign works','sign fails', sign(10).eq.1 .and. sign(-10).eq.-1 )
-----------------------------------------------^
xx.f90(23): error #6505: This intrinsic procedure reference contains too few arguments. [SIGN]
write(*,*) merge('sign works','sign fails', sign(10).eq.1 .and. sign(-10).eq.-1 )
```
-------------------------------------------------------------------^
compilation aborted for xx.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a compiler bug with being unable to resolve a generic interface. While it gets addressed, but a clearer instruction per the standard that all the processors will likely also prefer will be to move the `intrinsic` to the scope of the overriding procedure:
contains
elemental function sign_int32(value)
integer(kind=int32),intent(in) :: value
integer(kind=int32) :: sign_int32
intrinsic :: sign ! move the intrinsic to this subscope
sign_int32=sign(1_int32,value)
end function sign_int32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That does make is less ambigious as just the intrinsic is needed at that point, but the overlaid procedure is in scope, which makes for an
recursive situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good news! I ran this with the coming release of ifort 2021.9.0 and ifx 2023.1.0 and it compiles and runs!
$ ifx --version
ifx (IFX) 2023.1.0 20230216
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
$ ifx tryit.f90
$ a.out
sign works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your tryit.f90 test, was the line 7 uncommented? Assuming your test was the code in the original post with line 7 as "!intrinsic :: sign ! ifort 2023 bug(?)" OP had the line commented out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@FortranFan, I missed that subtlety on line 7. I get the same error message with the coming release.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bug filed, CMPLRLLVM-45073.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The erroneous error message is removed now in the Fortran compilers that were released last week as part of oneAPI HPC Toolkit 2023.2.
Please try it!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page