From cdbdf7ffa63ba5fc04e218084209d0e5ea116173 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Mon, 25 Dec 2023 19:57:52 +0100 Subject: [PATCH 1/3] Addition of a test that triggers an error with GFortran 11 and 12 --- test/bitsets/test_stdlib_bitset_64.f90 | 9 +++++++++ test/bitsets/test_stdlib_bitset_large.f90 | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/test/bitsets/test_stdlib_bitset_64.f90 b/test/bitsets/test_stdlib_bitset_64.f90 index d06082d00..d83c86d11 100644 --- a/test/bitsets/test_stdlib_bitset_64.f90 +++ b/test/bitsets/test_stdlib_bitset_64.f90 @@ -231,6 +231,15 @@ subroutine test_initialization(error) type(bitset_64) :: set4, set5 + !The following block triggers an issue in gfortran 11 and 12 + block + type(bitset_64) :: set6 + call check(error, set6 % bits(), 0, & + 'set6 % bits() returned non-zero value '//& + 'even though set6 was not initialized.') + if (allocated(error)) return + end block + set5 = log1 call check(error, set5%bits(), 64, & 'initialization with logical(int8) failed to set the right size.') diff --git a/test/bitsets/test_stdlib_bitset_large.f90 b/test/bitsets/test_stdlib_bitset_large.f90 index cd3204697..5f8db09bb 100644 --- a/test/bitsets/test_stdlib_bitset_large.f90 +++ b/test/bitsets/test_stdlib_bitset_large.f90 @@ -345,6 +345,15 @@ subroutine test_initialization(error) logical(int64), allocatable :: log8(:) type(bitset_large) :: set4, set5 + !The following triggers an issue in gfortran 11 and 12 + block + type(bitset_large) :: set6 + call check(error, set6 % bits(), 0, & + 'set6 % bits() returned non-zero value '//& + 'even though set6 was not initialized.') + if (allocated(error)) return + end block + set5 = log1 call check(error, set5 % bits(), 64, & ' initialization with logical(int8) failed to set' // & From 2bd5c413c0802c8aa2ec88e048f158ca8214f8d5 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Mon, 25 Dec 2023 20:13:01 +0100 Subject: [PATCH 2/3] Set to 0 the variable num_bits --- src/stdlib_bitsets.fypp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdlib_bitsets.fypp b/src/stdlib_bitsets.fypp index 5c9ffc0e5..36d9ae531 100644 --- a/src/stdlib_bitsets.fypp +++ b/src/stdlib_bitsets.fypp @@ -100,7 +100,7 @@ module stdlib_bitsets !! Parent type for bitset_64 and bitset_large ([Specification](../page/specs/stdlib_bitsets.html#the-stdlib_bitsets-derived-types)) private - integer(bits_kind) :: num_bits + integer(bits_kind) :: num_bits = 0_bits_kind contains From 217c373ed436729701aec7c03c6182c61e8d7ca2 Mon Sep 17 00:00:00 2001 From: Jeremie Vandenplas Date: Mon, 25 Dec 2023 20:13:13 +0100 Subject: [PATCH 3/3] Fix typo --- src/stdlib_bitsets_large.fypp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdlib_bitsets_large.fypp b/src/stdlib_bitsets_large.fypp index fef726525..0bc94bb01 100644 --- a/src/stdlib_bitsets_large.fypp +++ b/src/stdlib_bitsets_large.fypp @@ -1051,7 +1051,7 @@ contains pure module subroutine set_range_large(self, start_pos, stop_pos) ! ! Sets all valid bits to 1 from the START_POS to the STOP_POS positions -! in SELF. If STOP_POA < START_POS no bits are changed. Positions outside +! in SELF. If STOP_POS < START_POS no bits are changed. Positions outside ! the range 0 to BITS(SELF)-1 are ignored. ! class(bitset_large), intent(inout) :: self