- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code does some 'voodoo' using a C pointer, TRANSFER intrinsic, and what not, but it is standard-conforming as far as I can tell. It functions as expected when compiled using gfortran, however it runs into a program exception with Intel Fortran compiler. Note the exception arises with objects of ALLOCATABLE attribute; if line 7 is commented out and line 8 is uncommented in the main program, it works ok with Intel Fortran compiler and so it does with gfortran.
module m use, intrinsic :: iso_c_binding, only : c_loc, c_ptr, c_f_pointer implicit none private public :: get_s character(len=*), parameter :: s = "Hello World!" contains subroutine get_s( t, t_size ) type(*), intent(inout), target :: t(..) integer, intent(in) :: t_size blk: block character(len=t_size), pointer :: ptr_s => null() call c_f_pointer( cptr=c_loc(t), fptr=ptr_s ) ptr_s = transfer( source=s, mold=ptr_s ) ptr_s => null() end block blk return end subroutine get_s end module m
program p use m, only : get_s integer, parameter :: lens = 12 character(len=:), allocatable :: s !character(len=lens) :: s s = repeat( " ", ncopies=lens ) call get_s( s, len(s) ) print *, "s = ", s stop end program p
C:\..>ifort /c /standard-semantics /traceback /warn:all /check:all m.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R ) 64, Version 17.0.1.143 Build 20161005 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. C:\..>ifort /c /standard-semantics /traceback /warn:all /check:all p.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R ) 64, Version 17.0.1.143 Build 20161005 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. C:\..>link /out:p.exe /subsystem:console p.obj m.obj Microsoft (R) Incremental Linker Version 14.00.24215.1 Copyright (C) Microsoft Corporation. All rights reserved. C:\..>p.exe s = forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source p.exe 000000013FC46DE0 Unknown Unknown Unknown p.exe 000000013FC097C7 Unknown Unknown Unknown p.exe 000000013FC0143A MAIN__ 12 p.f90 p.exe 000000013FC4F3CE Unknown Unknown Unknown p.exe 000000013FC4FD5D Unknown Unknown Unknown kernel32.dll 0000000076E159CD Unknown Unknown Unknown ntdll.dll 000000007704A561 Unknown Unknown Unknown
P.S.> a typo (change use s_m to use m) in main program p corrected per Message #2
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For what it is worth that fails on 17 update 2 also, I suspect FF has not been "brave" enough to install that. There is a typo on the reproducer the module name I changed to s_m to match the use name.
C:\Users\Andrew\Desktop\fft>ifort /c /standard-semantics /traceback /warn:all /check:all m.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.2.187 Build 20170213 Copyright (C) 1985-2017 Intel Corporation. All rights reserved. C:\Users\Andrew\Desktop\fft>ifort /c /standard-semantics /traceback /warn:all /check:all p.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.2.187 Build 20170213 Copyright (C) 1985-2017 Intel Corporation. All rights reserved. C:\Users\Andrew\Desktop\fft>link /out:p.exe /subsystem:console p.obj m.obj Microsoft (R) Incremental Linker Version 12.00.40629.0 Copyright (C) Microsoft Corporation. All rights reserved. C:\Users\Andrew\Desktop\fft>p s = forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source p.exe 00007FF643BE60D9 Unknown Unknown Unknown p.exe 00007FF643BA9F47 Unknown Unknown Unknown p.exe 00007FF643BA143A MAIN__ 12 p.f90 p.exe 00007FF643BEFC0E Unknown Unknown Unknown p.exe 00007FF643BF0A50 Unknown Unknown Unknown KERNEL32.DLL 00007FFC93F08364 Unknown Unknown Unknown ntdll.dll 00007FFC94CE70D1 Unknown Unknown Unknown
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
andrew_4619 wrote:
For what it is worth that fails on 17 update 2 also, I suspect FF has not been "brave" enough to install that. There is a typo on the reproducer the module name I changed to s_m to match the use name. ..
Thanks much and a great catch on the typo, indeed I have not tried Update 2. If it's not too much trouble, can you please check whether a modified main, where line 7 is commented out and line 8 is uncommented, works with Update 2?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FortranFan wrote:
If it's not too much trouble, can you please check whether a modified main, where line 7 is commented out and line 8 is uncommented, works with Update 2?
Yes that works OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Andrew that's good to know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting this. I reported it to Development.
(Internal tracking id: DPD200418831)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page