https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102109
Bug ID: 102109 Summary: Associate to construct compound object results in incorrect type inferred Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: everythingfunctional at protonmail dot com Target Milestone: --- Using version Ubuntu 11.1.0-1ubuntu1~21.04 on Pop!OS Using nested associate constructs to construct a compound object of derived type results in the compiler rejecting the code with what it thinks is a type mismatch. Example code below program main type :: sub_obj_t integer :: val end type type :: compound_obj_t type(sub_obj_t) :: sub_obj end type associate(initial_sub_obj => sub_obj_t(42)) associate(obj => compound_obj_t(initial_sub_obj)) print *, obj%sub_obj%val end associate end associate end program app/main.f90:11:40: 11 | associate(obj => compound_obj_t(initial_sub_obj)) | 1 Error: Cannot convert INTEGER(4) to TYPE(sub_obj_t) at (1) Note: for a fun twist, if you remove the print statement, this does compile and run.