- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following simple code works fine with gfortran but fails with an unexpected "has stopped working" message with Intel compiler (version 16, update 1). It feels like one of those simple code constructs that has worked umpteen times previously with Intel compiler but something has changed which causes it to fail now. But I just can't figure out the problem.
module m use, intrinsic :: iso_c_binding, only : c_char, c_int, c_ptr, c_f_pointer use, intrinsic :: iso_fortran_env, only : output_unit implicit none contains subroutine Fsub( Str, LenStr ) bind(C, name="Fsub") !.. Argument list type(c_ptr), intent(in), value :: Str integer(c_int), intent(in), value :: LenStr blk: block character(kind=c_char,len=LenStr), pointer :: f_str => null() call c_f_pointer( Str, f_str ) write(output_unit,*) "In Fsub: Str is ", f_str f_str => null() end block blk !.. return end subroutine Fsub end module m
#include <string.h> void Fsub(const char *, int); int main() { const char * s = "Hello World!"; int len_s; len_s = strlen(s); Fsub(s, len_s); return(0); }
C:\temp>ifort /c /standard-semantics /warn:all f.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R ) 64, Version 16.0.1.146 Build 20151021 Copyright (C) 1985-2015 Intel Corporation. All rights reserved. C:\temp>cl /c c.c Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x64 Copyright (C) Microsoft Corporation. All rights reserved. c.c C:\temp>link c.obj f.obj /out:p.exe Microsoft (R) Incremental Linker Version 12.00.40629.0 Copyright (C) Microsoft Corporation. All rights reserved. C:\temp>p
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It isn't the C_F_POINTER, the error is happening as soon as the BLOCK is entered. We'll take a closer look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Escalated as issue DPD200381625.For some reason the compiler is trying to copy the string just setting up the pointer, but using a NULL address to do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve for your follow-up. Yes, BLOCK seems to be the problem - it works without it.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page