Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

RESHAPE with zero size input and padding blows stack

IanH
Honored Contributor III
603 Views

The following:
 

[fortran]PROGRAM BlowMyStack
  IMPLICIT NONE
  CALL TestProc
CONTAINS
  SUBROUTINE TestProc  
    CALL Proc2(RESHAPE([INTEGER::], [10], [1]))
  END SUBROUTINE
  
  SUBROUTINE Proc2(arr)
    INTEGER, INTENT(IN) :: arr(:)
    PRINT *, arr
  END SUBROUTINE Proc2

END PROGRAM BlowMyStack

[/fortran]

dies with a stack overflow when run after compiling with 12.1.1 with /Od on ia32.
 

[plain]H:\projects\FortranMisc>ifort /check:all /warn:all /standard-semantics /Od /traceback stack.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

Microsoft  Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:stack.exe
-subsystem:console
-incremental:no
stack.obj

H:\projects\FortranMisc>stack
forrtl: severe (170): Program Exception - stack overflow
Image              PC        Routine            Line        Source
stack.exe          00E0E957  Unknown               Unknown  Unknown
stack.exe          00DE1021  _MAIN__                     3  stack.f90
stack.exe          00E288F3  Unknown               Unknown  Unknown
stack.exe          00E0EA8F  Unknown               Unknown  Unknown
kernel32.dll       761AD309  Unknown               Unknown  Unknown
ntdll.dll          76F716C3  Unknown               Unknown  Unknown
ntdll.dll          76F71696  Unknown               Unknown  Unknown[/plain]
0 Kudos
2 Replies
Steven_L_Intel1
Employee
603 Views
Very interesting. The compiler is using an uninitialized value when computing the size of the zero-sized array constructor. Escalated as DPD200175839. Incidentally, I found this very difficult to reproduce (as in get an error) from the command line - even using the same command you did. But I could reproduce it in the debugger and saw what was causing the problem.
0 Kudos
Steven_L_Intel1
Employee
603 Views
This has been fixed for a release later this year.
0 Kudos
Reply