Skip to content

Commit 2d7fe21

Browse files
committed
Fix another polymorphic assignment bug in gfortran 13.2
1 parent 7a781a4 commit 2d7fe21

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

ChangeLog.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Workaround additional polymorphic assignment bug in gfortran 13.2 (in build_locks)
13+
1014
## [1.13.2] - 2024-03-13
1115

1216
### Fixed

src/Config.F90

+34-32
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module PFL_Config
1818
use PFL_Formatter
1919
use PFL_Filterer
2020
use PFL_FileHandler
21-
21+
2222
use gFTL2_StringUnlimitedMap
2323
use PFL_Filter
2424
use PFL_StringUtilities, only: to_lower_case
@@ -77,7 +77,7 @@ subroutine build_formatters(this, cfg, unusable, extra, rc)
7777
class(NodeIterator), allocatable :: iter
7878
class (Formatter), allocatable :: f
7979
character(:), allocatable :: formatter_name
80-
80+
8181
integer :: status
8282

8383
_ASSERT(cfg%is_mapping(), "PFL::Config::build_formatters() - input cfg not a mapping", rc)
@@ -123,7 +123,7 @@ subroutine build_formatter(fmtr, cfg, unusable, extra, global_communicator, rc)
123123
select case (class_name)
124124
case ('Formatter')
125125
call build_basic_formatter(fmtr, cfg, _RC)
126-
#ifdef _LOGGER_USE_MPI
126+
#ifdef _LOGGER_USE_MPI
127127
case ('MpiFormatter')
128128
if (present(extra)) then
129129
extra_ = extra
@@ -287,7 +287,7 @@ subroutine build_mpi_formatter(fmtr, cfg, unusable, extra, rc)
287287
_RETURN(_SUCCESS,rc)
288288
end subroutine build_mpi_formatter
289289
#endif
290-
290+
291291
subroutine build_locks(this, cfg, unusable, extra, rc)
292292
use PFL_AbstractLock
293293
#ifdef _LOGGER_USE_MPI
@@ -304,7 +304,7 @@ subroutine build_locks(this, cfg, unusable, extra, rc)
304304
character(:), allocatable :: lock_name
305305
class (AbstractLock), allocatable :: lock
306306
integer :: status
307-
307+
308308
_ASSERT(cfg%is_mapping(), "PFL::Config::build_locks() - input cfg not a mapping", rc)
309309

310310
associate (b => cfg%begin(), e => cfg%end())
@@ -313,7 +313,9 @@ subroutine build_locks(this, cfg, unusable, extra, rc)
313313

314314
lock_name = to_string(iter%first(), _RC)
315315
subcfg => iter%second()
316-
lock = build_lock(subcfg, extra=extra, _RC)
316+
!lock = build_lock(subcfg, extra=extra, _RC)
317+
allocate(lock, source=build_lock(subcfg, extra=extra, rc=status))
318+
_VERIFY(status,'',rc)
317319
call this%locks%insert(lock_name, lock)
318320
call iter%next()
319321
end do
@@ -376,7 +378,7 @@ subroutine build_filters(this, cfg, unusable, extra, rc)
376378

377379
associate (b => cfg%begin(), e => cfg%end())
378380
iter = b
379-
381+
380382
do while (iter /= e)
381383

382384
filter_name = to_string(iter%first(), _RC)
@@ -407,7 +409,7 @@ function build_filter(cfg, unusable, extra, rc) result(f)
407409

408410
character(len=:), allocatable :: class_name
409411
integer :: status
410-
412+
411413
_ASSERT(cfg%is_mapping(), "PFL::Config::build_formatter() - input cfg not a mapping", rc)
412414

413415
if (cfg%has('class')) then
@@ -420,12 +422,12 @@ function build_filter(cfg, unusable, extra, rc) result(f)
420422
case ('filter')
421423
allocate(f, source=build_basic_filter(cfg, rc=status))
422424
_VERIFY(status, '', rc)
423-
425+
424426
case ('levelfilter')
425427
allocate(f, source=build_LevelFilter(cfg, rc=status))
426428
_VERIFY(status, '', rc)
427-
428-
#ifdef _LOGGER_USE_MPI
429+
430+
#ifdef _LOGGER_USE_MPI
429431
case ('mpifilter')
430432
allocate(f, source=build_MpiFilter(cfg, extra=extra, rc=status))
431433
_VERIFY(status, '', rc)
@@ -443,7 +445,7 @@ function build_basic_filter(cfg, rc) result(f)
443445
type (Filter) :: f
444446
class(YAML_Node), intent(in) :: cfg
445447
integer, optional, intent(out) :: rc
446-
448+
447449
character(len=:), allocatable :: name
448450
integer :: status
449451

@@ -461,18 +463,18 @@ function build_LevelFilter(cfg, rc) result(f)
461463
type (LevelFilter) :: f
462464
class(YAML_Node), intent(in) :: cfg
463465
integer, optional, intent(out) :: rc
464-
466+
465467
integer :: min_level, max_level
466468
integer :: status
467469

468470
min_level = get_level('min_level', _RC)
469471
max_level = get_level('max_level', _RC)
470-
472+
471473
f = LevelFilter(min_level, max_level)
472-
474+
473475
_RETURN(_SUCCESS,rc)
474476
contains
475-
477+
476478
integer function get_level(key, rc) result(level)
477479
character(len=*), intent(in) :: key
478480
integer, optional, intent(out) :: rc
@@ -493,7 +495,7 @@ integer function get_level(key, rc) result(level)
493495

494496
_RETURN(_SUCCESS,rc)
495497
end function get_level
496-
498+
497499
end function build_LevelFilter
498500

499501
#ifdef _LOGGER_USE_MPI
@@ -504,7 +506,7 @@ function build_MpiFilter(cfg, unusable, extra, rc) result(f)
504506
class (KeywordEnforcer), optional, intent(in) :: unusable
505507
type (StringUnlimitedMap), optional, intent(in) :: extra
506508
integer, optional, intent(out) :: rc
507-
509+
508510
character(len=:), allocatable :: comm_name
509511
integer :: comm
510512
integer :: rank, root, ierror
@@ -528,7 +530,7 @@ function build_MpiFilter(cfg, unusable, extra, rc) result(f)
528530
_UNUSED_DUMMY(unusable)
529531
end function build_MpiFilter
530532
#endif
531-
533+
532534

533535
subroutine build_handlers(this, cfg, unusable, extra, rc)
534536
class (ConfigElements), intent(inout) :: this
@@ -558,7 +560,7 @@ subroutine build_handlers(this, cfg, unusable, extra, rc)
558560

559561
_RETURN(_SUCCESS,rc)
560562
end subroutine build_handlers
561-
563+
562564
subroutine build_handler(h, cfg, elements, unusable, extra, rc)
563565
class (AbstractHandler), allocatable, intent(out) :: h
564566
class(YAML_Node), intent(inout) :: cfg
@@ -568,7 +570,7 @@ subroutine build_handler(h, cfg, elements, unusable, extra, rc)
568570
integer, optional, intent(out) :: rc
569571

570572
integer :: status
571-
573+
572574
call allocate_concrete_handler(h, cfg, _RC)
573575
call set_handler_level(h, cfg, _RC)
574576
call set_handler_formatter(h, cfg, elements%formatters, _RC)
@@ -600,11 +602,11 @@ subroutine allocate_concrete_handler(h, cfg, rc)
600602
case ('filehandler')
601603
call build_filehandler(fh, cfg)
602604
allocate(h, source=fh)
603-
#ifdef _LOGGER_USE_MPI
605+
#ifdef _LOGGER_USE_MPI
604606
case ('mpifilehandler')
605607
call build_mpifilehandler(fh, cfg)
606608
allocate(h, source=fh)
607-
#endif
609+
#endif
608610
case default
609611
_ASSERT(.false., "PFL::Config::build_handler() - unsupported class: '" // class_name //"'.", rc)
610612
end select
@@ -614,7 +616,7 @@ end subroutine allocate_concrete_handler
614616
subroutine set_handler_level(h, cfg, rc)
615617
class (AbstractHandler), intent(inout) :: h
616618
class(YAML_Node), intent(in) :: cfg
617-
integer, optional, intent(out) :: rc
619+
integer, optional, intent(out) :: rc
618620

619621
character(len=:), allocatable :: level_name
620622
integer :: level
@@ -638,7 +640,7 @@ subroutine set_handler_level(h, cfg, rc)
638640

639641
_RETURN(_SUCCESS,rc)
640642
end subroutine set_handler_level
641-
643+
642644

643645
subroutine set_handler_formatter(h, cfg, formatters, rc)
644646
use PFL_Formatter
@@ -726,7 +728,7 @@ subroutine set_handler_lock(h, cfg, locks, rc)
726728
end if
727729
_RETURN(_SUCCESS,rc)
728730
end subroutine set_handler_lock
729-
731+
730732

731733
end subroutine build_handler
732734

@@ -893,8 +895,8 @@ subroutine build_mpifilehandler(h, cfg, unusable, extra, rc)
893895
end if
894896

895897
h = FileHandler(fileName, delay=delay)
896-
897-
_RETURN(_SUCCESS,rc)
898+
899+
_RETURN(_SUCCESS,rc)
898900
end subroutine build_mpifilehandler
899901
#endif
900902

@@ -990,7 +992,7 @@ subroutine set_logger_propagate(lgr, cfg, rc)
990992

991993
_RETURN(_SUCCESS,rc)
992994
end subroutine set_logger_propagate
993-
995+
994996

995997
subroutine set_logger_filters(lgr, cfg, filters, unusable, extra, rc)
996998
class (Logger), intent(inout) :: lgr
@@ -1034,15 +1036,15 @@ subroutine set_logger_handlers(lgr, cfg, handlers, unusable, extra, rc)
10341036
type (StringUnlimitedMap), optional, intent(in) :: extra
10351037
integer, optional, intent(out) :: rc
10361038

1037-
character(len=:), allocatable :: handler_name
1039+
character(len=:), allocatable :: handler_name
10381040
class(YAML_Node), pointer :: subcfg
10391041
integer :: i
10401042
integer :: status
10411043

10421044
if (cfg%has('handlers')) then
10431045
subcfg => cfg%of('handlers')
10441046
_ASSERT(cfg%has('handlers'), "PFL::Config::set_logger_handlers() - expected sequence for 'handlers' key.", rc)
1045-
1047+
10461048
do i = 1, subcfg%size()
10471049
call subcfg%get(handler_name, i, _RC)
10481050

@@ -1145,7 +1147,7 @@ subroutine set_global_communicator(this, comm)
11451147
class (ConfigElements), intent(inout) :: this
11461148
integer, optional, intent(in) :: comm
11471149

1148-
#ifdef _LOGGER_USE_MPI
1150+
#ifdef _LOGGER_USE_MPI
11491151
if (present(comm)) then
11501152
this%global_communicator = comm
11511153
else

0 commit comments

Comments
 (0)