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

Intel compiler giving error due to whitespace in assumed rank dummy argument declaration

Shrublet
Beginner
560 Views

 

(Please See https://stackoverflow.com/questions/79834684/intel-compiler-giving-error-due-to-whitespace-in-assumed-rank-dummy-argument-dec for the original)

 

Consider the following code:

Module assumed_rank_module

  Implicit None

Contains

  Pure Function assumed_rank( a ) Result( s )

    Integer :: s

    Real, Dimension( .. ), Intent( In ) :: a

    s = Size( a )

  End Function assumed_rank
  
End Module assumed_rank_module

Gfortran is happy with this:

ijb87_local@SCLT517LINUX:~/play/stack$ gfortran --version
GNU Fortran (GCC) 15.2.0
Copyright © 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ijb87_local@SCLT517LINUX:~/play/stack$ gfortran -c -Wall -Wextra -pedantic -fcheck=all -std=f2018 -Og -g ass_rank.f90 
ijb87_local@SCLT517LINUX:~/play/stack$ 

Amdflang is happy with this:

ijb87_local@SCLT517LINUX:~/play/stack$ amdflang --version
AMD AFAR drop #6.0 03/23/25 flang version 21.0.0git (ssh://github-emu/AMD-Lightning-Internal/llvm-project  25126 b659d5b9bd0f2e3a0111a02e93ec1b3fa38a39a7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/ijb87_local/tools/amd/rocm-afar-7450-drop-6.0.0/lib/llvm/bin
Build config: +assertions
Configuration file: /home/ijb87_local/tools/amd/rocm-afar-7450-drop-6.0.0/lib/llvm/bin/flang.cfg
ijb87_local@SCLT517LINUX:~/play/stack$ amdflang -c -O ass_rank.f90
ijb87_local@SCLT517LINUX:~/play/stack$ 

Even the nvidia compiler is happy with this (after I had taken out ( Type, External ) on Implicit None ...):

ijb87_local@SCLT517LINUX:~/play/stack$ /opt/nvidia/hpc_sdk/Linux_x86_64/25.9/compilers/bin/nvfortran --version
nvfortran 25.9-0 64-bit target on x86-64 Linux -tp alderlake 
NVIDIA Compilers and Tools
Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
ijb87_local@SCLT517LINUX:~/play/stack$ /opt/nvidia/hpc_sdk/Linux_x86_64/25.9/compilers/bin/nvfortran -c ass_rank.f90 
ijb87_local@SCLT517LINUX:~/play/stack$ 

However ifx complains about, of all things, the space after the .. :

ijb87_local@SCLT517LINUX:~/play/stack$ ifx --version
ifx (IFX) 2025.2.0 20250605
Copyright (C) 1985-2025 Intel Corporation. All rights reserved.

ijb87_local@SCLT517LINUX:~/play/stack$ ifx -c ass_rank.f90
ass_rank.f90(11): error #5145: Invalid blank/tab
    Real, Dimension( .. ), Intent( In ) :: a
-----------------------^
compilation aborted for ass_rank.f90 (code 1)

If I remove that space ifx is happy:

ijb87_local@SCLT517LINUX:~/play/stack$ cat ass_rank.f90
Module assumed_rank_module

  Implicit None

Contains

  Pure Function assumed_rank( a ) Result( s )

    Integer :: s

    Real, Dimension( ..), Intent( In ) :: a

    s = Size( a )

  End Function assumed_rank
  
End Module assumed_rank_module
ijb87_local@SCLT517LINUX:~/play/stack$ ifx -c ass_rank.f90
ijb87_local@SCLT517LINUX:~/play/stack$ 

This looks like a (somewhat peculiar) bug in the Intel compiler, a view that is supported on Stack Overflow. As I'm new here is this the right place to report it?

 

0 Kudos
7 Replies
Mark_Lewy
Valued Contributor I
544 Views

Still fails to compile in IFX 2025.3.1 Linux and Windows without removing the trailing space.

The Fortran standard is ambiguous on whether this is a bug or not (looking at J3/SD-007):

R814 says that array-spec can be an assumed-rank-spec (among others) (8.5.8.1 DIMENSION attribute/General)

R827 assumed-rank-spec is .. (8.5.8.7)

There is no mention of trailing or leading white-space.

 

Modern Fortran Explained (Fortran 2018 edition) has "... assumed rank with the syntax (..)." in 23.16.1 Assumed-rank objects, so perhaps the IFX implementation took that as inspiration?

0 Kudos
Shrublet
Beginner
518 Views

 

It seems a bit strange that the compiler allows a space before the .. , but complains about one directly afterwards

0 Kudos
Mark_Lewy
Valued Contributor I
508 Views

Yes, it does appear strange.  Also, the compiler is perfectly happy with whitespace around an assumed shape argument, for example:

Real, Dimension( : ), Intent( In ) :: a

Hopefully, someone from Intel will read this and investigate further.

0 Kudos
andrew_4619
Honored Contributor III
530 Views
      Function assumed_rank( a ) Result( s )
      Integer :: s
      Real, Dimension( .. ), Intent( In ) :: a
      s = Size( a )
      End Function assumed_rank

But it is ok in IFX in fixed form (.for file rather the .f90 file). Spaces do matter in freeform but do ".." and ")" count as lexical tokens.....?

0 Kudos
JFH
New Contributor I
439 Views

Both ".." and ")" are lexical tokens by F2023 3.95 6.2.6.

0 Kudos
andrew_4619
Honored Contributor III
430 Views
In free source form blank characters shall not appear within lexical tokens other than in a character context or in
a format specification. Blanks may be inserted freely between tokens to improve readability; for example, blanks
may occur between the tokens that form a complex literal constant. A sequence of blank characters outside of a
character context is equivalent to a single blank character.


Standard quote. It says bug.
0 Kudos
Igor_V_Intel
Moderator
200 Views

I have escalated it to Intel support, so,  Intel development team should take a look and hopefully fix it in the upcoming compiler versions.

0 Kudos
Reply