<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compiler bug: wrong type-bound procedure called in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1664686#M175021</link>
    <description>&lt;P&gt;Our team also encountered this bug with the following configuration:&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;Compiler&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: ifx (IFX) 2024.2.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;OS&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: Linux Mint 21.3 (Virginia)&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 17:47:50 GMT</pubDate>
    <dc:creator>WileyOne</dc:creator>
    <dc:date>2025-02-10T17:47:50Z</dc:date>
    <item>
      <title>Compiler bug: wrong type-bound procedure called</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1664684#M175020</link>
      <description>&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;Compiler&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: ifx (IFX) 2025.0.4&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;OS&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: Rocky Linux 8.9 (Green Obsidian)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;This is a strange one. The code compiles fine but crashes at runtime; it seems to be an issue with the underlying procedure table. In short, the wrong type-bound procedure is called, eventually leading the program to crash.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;The following is a much reduced example from our team's architecture.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;I expect the type-bound procedure `run` on class `component` to be called, but the example crashes on line 98. As I paired down code from our original situation, the behavior of the program varied at this location; s&lt;/SPAN&gt;&lt;SPAN class=""&gt;ometimes the obviously wrong procedure would be called, other times&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;it would enter an endless loop until a stack overflow occurred, and still others crashed immediately (like the provided example). It is this behavior that original led me to suspect a compiler bug.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;module Component_Header
    implicit none
    private
    public :: component, componentList

    type :: component
        contains
        procedure, public :: run
    end type

    type Element
        class(component), allocatable :: object
    end type

    type componentList
        private

        type(Element), pointer :: item =&amp;gt; null()

        contains
        final           :: final_componentList
        generic, public :: assignment(=) =&amp;gt; copy_componentList

        procedure, public :: &amp;amp;
            add =&amp;gt; add_componentList, &amp;amp;
            get =&amp;gt; get_componentList

        procedure, private :: &amp;amp;
            copy_componentList
    end type

    contains

    subroutine run(this)
        class(component), intent(inout) :: this
        print *, 'this routine should run'
    end subroutine

    subroutine final_componentList(this)
        type(componentList) :: this

        if (associated(this%item)) deallocate(this%item)
    end subroutine

    subroutine copy_componentList(lhs,rhs)
        class(componentList), intent(out) :: lhs
        class(componentList), intent(in)  :: rhs

        call lhs%add(rhs%item%object)
    end subroutine

    subroutine add_componentList(this,something)
        class(componentList), target, intent(inout) :: this
        class(component),             intent(in)    :: something

        allocate(this%item)
        this%item%object = something
    end subroutine

    function get_componentList(this) result(something)
        class(componentList), target, intent(in) :: this
        class(component),        pointer :: something

        something =&amp;gt; this%item%object
    end function

end module

module Container_Header
    use Component_Header
    implicit none
    private
    public :: Container

    type :: Container ! oddity #1
        type(componentList) :: components
        contains
        procedure, public :: &amp;amp;
            runComponents, &amp;amp;
            addComponent
    end type

    contains

    subroutine addComponent(this)
        class(Container), intent(inout) :: this

        call this%components%add(component())
    end subroutine

    subroutine runComponents(this)
        class(Container), intent(inout) :: this

        class(component), pointer :: comp =&amp;gt; null()
        
        print *, 'running the container'
        comp =&amp;gt; this%components%get()
        call comp%run() !!! this line breaks !!!
    end subroutine

end module

module Mode_Header
    use Container_Header
    implicit none
    private
    public :: mode, mode_constructor

    type :: ModeInterface ! oddity #2
    end type

    type, extends(ModeInterface) :: mode
        type(Container) :: myContainer
        contains
        procedure, public :: execute
    end type

    contains

    function mode_constructor() result(this) ! oddity #3
        type(mode) :: this

        call this%myContainer%addComponent()
    end function

    subroutine execute(this)
        class(mode), intent(inout) :: this
        print *, 'execute was called'
        call this%myContainer%runComponents()
    end subroutine

end module

program main
    use Mode_Header
    implicit none
    type(mode) :: myMode

    myMode = mode_constructor()
    call myMode%execute()
end program&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;This code is also attached as a file below. Any and all help is appreciated.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;FONT size="5"&gt;Additional Details&lt;/FONT&gt;&lt;/P&gt;&lt;P class=""&gt;Someone might initially be tempted to think that a dangling pointer causes this crash. After all, the `component` object created on line 88 is finalized when exiting the constructor on line 139, so the new `item` pointer existing within in `myMode` is now referencing invalid memory. While it's true that the original `component` object is finalized, the class `componentList` has a defined `assignment` operator - `copy_componentList` - that performs a deep copy. Therefore, the `item` pointer within the `myMode` object references its own copy of `component`. Stepping through the program with gdb confirms that these routines behave as expected.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Note some of the oddities I observed when pairing down our architecture to the given example:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Cutting `Container` and moving its functionality into `mode` causes the error to vanish.&lt;/LI&gt;&lt;LI&gt;Extending `mode` from `ModeInterface` produces the bug but behaves as expected when `mode` is not an extension of a base class.&lt;/LI&gt;&lt;LI&gt;Switching the routine `mode_constructor` from a function to a subroutine fixes the error. This is not the case, however, where we originally encountered the bug.&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;These are not realistic workarounds for our situation; again, this is a significant simplification from our framework. Certain aspects seems silly separated from their context.&amp;nbsp;I am simply explaining why certain features were included in the bugged example.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 17:46:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1664684#M175020</guid>
      <dc:creator>WileyOne</dc:creator>
      <dc:date>2025-02-10T17:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler bug: wrong type-bound procedure called</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1664686#M175021</link>
      <description>&lt;P&gt;Our team also encountered this bug with the following configuration:&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;Compiler&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: ifx (IFX) 2024.2.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;OS&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;: Linux Mint 21.3 (Virginia)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 17:47:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1664686#M175021</guid>
      <dc:creator>WileyOne</dc:creator>
      <dc:date>2025-02-10T17:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler bug: wrong type-bound procedure called</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700021#M176144</link>
      <description>&lt;P&gt;As of 2025.2.0 this is now working. I will wait for confirmation from one of the admins before marking this issue as resolved.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 17:11:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700021#M176144</guid>
      <dc:creator>WileyOne</dc:creator>
      <dc:date>2025-06-26T17:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler bug: wrong type-bound procedure called</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700057#M176145</link>
      <description>&lt;P&gt;Yes, the fix for this bug is in 2025.2.0.&amp;nbsp; I also confirmed the fix just to be sure:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;$ ifx -g -O0 -traceback -what -V test.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2025.2.0 Build 20250605
Copyright (C) 1985-2025 Intel Corporation. All rights reserved.

 Intel(R) Fortran 25.0-1485
GNU ld version 2.35.2-17.el9

$ ./a.out
 execute was called
 running the container
 this routine should run
$ 
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Jun 2025 22:13:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700057#M176145</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2025-06-26T22:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler bug: wrong type-bound procedure called</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700144#M176149</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/52256"&gt;@Ron_Green&lt;/a&gt;. Please pass along thanks from our team to the developers!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jun 2025 11:36:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-wrong-type-bound-procedure-called/m-p/1700144#M176149</guid>
      <dc:creator>WileyOne</dc:creator>
      <dc:date>2025-06-27T11:36:39Z</dc:date>
    </item>
  </channel>
</rss>

