# Problem passing the real part of a complex using %re syntax

**URL:** <https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430>\
**Category:** Intel\
**Created:** [March 21, 2025, 2:49pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430 "2025-03-21T14:49:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [March 21, 2025, 2:49pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/1 "2025-03-21T14:49:25Z")

</div>

I was surprised by an error generated by ifx 2025.0.0 20241008 (Ubuntu) concerning those pieces of code:

```fortran
    subroutine testc(calcul, attendu, precision)
        complex(wp), intent(in) :: calcul, attendu
        real(wp), intent(in) :: precision

        call testr(calcul%re, attendu%re, precision)
        ...
    end subroutine

    subroutine testr(calcul, attendu, precision)
        real(wp), intent(in) :: calcul, attendu, precision

```

The error is:

```auto
././src/RAY3D_libunit.f90(58): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined. [CALCUL]
        call testr(calcul%re, attendu%re, precision)
-------------------^

```

No problem with gfortran 14.2.0.  
I had the strange intuition to put those access to the real part of a complex between parenthesis:

```fortran
        call testr((calcul%re), (attendu%re), precision)

```

and now ifx compiles it without problem.  
Is there any reason for this behavior?

N.B. Same problem of course with `%im` syntax.

---

<div class="post-metadata">

**Author:** ![themos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/themos/32/521_2.png) [@themos](https://fortran-lang.discourse.group/u/themos)\
**Post date:** [March 21, 2025, 3:14pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/2 "2025-03-21T15:14:17Z")

</div>

It’s a mistake, the compiler is issuing an error for conforming code. Putting the designator X%RE in brackets forces interpretation of the actual argument as an expression, which cannot become defined or undefined, so the check for this spurious error is not done.  
Arguably, leaving the workaround brackets in the source is a good reminder to the next human that those complex variables are not going to be modified by the procedure reference.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [March 21, 2025, 3:19pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/3 "2025-03-21T15:19:08Z")

</div>

Here is a minimalist fpm project reproducing the error with ifx:

```fortran
module strange
  implicit none
  private

  public :: say_hello
contains
  subroutine receive(x, y)
    real, intent(in) :: x, y
  end subroutine

  subroutine inter(z)
    complex, intent(in) :: z
    call receive(z%re, z%im)
  end subroutine

  subroutine say_hello
    complex :: z = (2.0, 3.0)
    call inter(z)
  end subroutine
end module strange

```

I needed to add the `inter(z)` subroutine to reproduce the error. Calling the `receive()` subroutine directly from `say_hello` would compile.

```bash
$ fpm run --compiler ifx
fpm: Entering directory '/tmp/strange'
strange.f90 failed.
[25%] Compiling...
././src/strange.f90(13): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined. [Z]
    call receive(z%re, z%im)
-----------------^

```

---

<div class="post-metadata">

**Author:** ![themos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/themos/32/521_2.png) [@themos](https://fortran-lang.discourse.group/u/themos)\
**Post date:** [March 21, 2025, 3:24pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/4 "2025-03-21T15:24:28Z")

</div>

Compiler Explorer suggests that previous versions of ifx were not complaining about this case.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [March 21, 2025, 3:25pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/5 "2025-03-21T15:25:40Z")

</div>

I think so, because I did not touch my computing model for one or two years, but it was indeed running without problem with ifx before.

Updated: same problem with ifx (IFX) 2025.1.0 20250317 that just arrived in Ubuntu.

---

<div class="post-metadata">

**Author:** ![zerothi](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@zerothi](https://fortran-lang.discourse.group/u/zerothi)\
**Post date:** [March 27, 2025, 1:25pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/6 "2025-03-27T13:25:21Z")

</div>

Has anybody reported this upstream?

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [March 27, 2025, 2:09pm UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/7 "2025-03-27T14:09:12Z")

</div>

related:

> **[Re: Issues with complex part designators](https://community.intel.com/t5/Intel-Fortran-Compiler/Issues-with-complex-part-designators/m-p/1430353/highlight/true)**
>
> I have to agree with Steve.  This looks like a bug in the Front End, the parsing of the language.  The runtime issue is falling out from that.  If the Front End does not properly identify a variable reference versus an expression...

> **[Re: Possible compiler bug? Passing components of complex arrays to Fortran...](https://community.intel.com/t5/Intel-Fortran-Compiler/COMPILER-BUG-Passing-components-of-complex-arrays-to-Fortran/m-p/1322629/highlight/true)**
>
> There haven't been bugfix change logs for years. Only people with paid support can file an official report. But the Intel support engineers often pick up issues from this forum.

But I do not see a new entry. Looks like it might be a regression.

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [April 7, 2025, 9:14am UTC](https://fortran-lang.discourse.group/t/problem-passing-the-real-part-of-a-complex-using-re-syntax/9430/8 "2025-04-07T09:14:30Z")

</div>

I tried adapting your test to see if the `%kind` designator also triggers problems, but it appears to work. Probably the `%kind` designator is treated differently at the level of types, and not like `%re` and `%im` which need to exist at the level of variables.
