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

Overloaded structure constructor merriment

IanH
Honored Contributor III
423 Views

Current ifort/ifx are confused by overloaded structure constructors in the face of any sort of module hierarchy.  The attached fails to compile...

>ifx /c /standard-semantics /check:all /warn:all broken_constructor_overload.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.0 Build 20240602
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

broken_constructor_overload.f90(24): remark #7712: This variable has not been used.   [ARG]
  FUNCTION construct_c_given_b(arg) RESULT(r)
-------------------------------^
broken_constructor_overload.f90(50): error #6053: Structure constructor may not have components with the PRIVATE attribute   [B_ARG]
    c_var = type_c(b_arg)
-------------------^
broken_constructor_overload.f90(50): error #8001: The type of the component in a structure-constructor differs from the type of the component in the derived-type-def.   [B_ARG]
    c_var = type_c(b_arg)
-------------------^
compilation aborted for broken_constructor_overload.f90 (code 1)

But comment out the use statement marked <--- in the proc module procedure, and all is well. 

This rather suggests that dependent modules are not correctly passing on the "along with this type there is a generic interface with the same name as the type that is to a function that then supplements/supplants the structure constructor" feature of Fortran 2003.

0 Kudos
1 Reply
TobiasK
Moderator
348 Views

@IanH


thanks for reporting that, I escalated it to our developers.


0 Kudos
Reply