Skip to content

Commit 33dbb04

Browse files
authored
Merge pull request #87 from Goddard-Fortran-Ecosystem/hotfix/#86-double-allocate
Fixes #86 - double allocate in workaround
2 parents 77044cd + d875757 commit 33dbb04

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if (COMMAND cmake_policy)
44
endif (COMMAND cmake_policy)
55

66
project (GFTL
7-
VERSION 1.2.1
7+
VERSION 1.2.2
88
LANGUAGES NONE)
99

1010
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@@ -35,7 +35,7 @@ if (PFUNIT_FOUND)
3535
add_custom_target(tests COMMAND ${CMAKE_CTEST_COMMAND})
3636
endif ()
3737

38-
add_subdirectory(tests)
38+
add_subdirectory(tests EXCLUDE_FROM_ALL)
3939
endif ()
4040

4141
configure_file(GFTLConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/GFTLConfig.cmake @ONLY)

ChangeLog.MD

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.2.2 2019-11-15
2+
- bugfix for workaround in v1.2.1; some use cases were not
3+
deallocating structure components prior to reallocation.
4+
15
1.2.1 2019-11-07
26
- added workaround for memory leak detected with Intel 18 compiler
37

cmake_utils/Intel.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(traceback "-traceback")
1414
set(cpp "-cpp")
1515

1616

17-
set(CMAKE_Fortran_FLAGS_DEBUG "${no_optimize}")
17+
set(CMAKE_Fortran_FLAGS_DEBUG "${no_optimize} ${check_all} ${traceback} -save-temps")
1818
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
1919
set(CMAKE_Fortran_FLAGS "-g ${cpp} ${traceback} ${check_all} ${disable_warning_for_long_names} -save-temps")
2020

include/templates/map.inc

+12-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,19 @@
156156
#ifdef __PAIR_ASSIGN
157157
# define __USE_ASSIGN(dest,src) __PAIR_ASSIGN(dest,src)
158158
#else
159-
# define __USE_ASSIGN(dest,src) __KEY_ASSIGN(dest%key,src%key); __VALUE_ASSIGN(dest%value,src%value)
159+
# define __USE_ASSIGN(dest,src) __KEY_ASSIGN(dest%key,src%key);__VALUE_ASSIGN(dest%value,src%value)
160+
#endif
161+
162+
#define __USE_MOVE(dest,src) __KEY_MOVE(dest%key,src%key);__VALUE_MOVE(dest%value,src%value)
163+
164+
#ifdef __PAIR_FREE
165+
# define __USE_FREE(x) __PAIR_FREE(x)
166+
#else
167+
! FREE can be an empty string, but Fortran does not allow a bare ";".
168+
! The kludge is to put in a conditional that is always true.
169+
# define __USE_FREE(x) if(.true.)then;__KEY_FREE(x%key); __VALUE_FREE(x%value);endif
170+
!# define __USE_FREE(x)
160171
#endif
161-
#define __USE_MOVE(dest,src) __KEY_MOVE(dest%key,src%key); __VALUE_MOVE(dest%value,src%value)
162-
#define __USE_FREE(x)
163172

164173
#ifdef _alt
165174
! vector<_type>

tests/Map/Test_map_double_assign.pf

+16
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,20 @@ contains
9292
end subroutine test_unlimited
9393
#endif
9494

95+
96+
! Reproducer for bug introduced in 1.2.1
97+
! Issue #86
98+
@test
99+
subroutine test_set_twice()
100+
use Foo_mod
101+
use integerFooPolyaltMap_mod
102+
103+
type (Map), target :: m
104+
class (Foo), pointer :: p1, p2
105+
106+
call m%insert(1, Foo(1))
107+
call m%set(1, Foo(2)) ! set() must first deallocate
108+
109+
end subroutine test_set_twice
110+
95111
end module Test_map_double_assign

0 commit comments

Comments
 (0)