Skip to content

Commit 18a2628

Browse files
committed
Zero-initialize comm pack buffers to avoid undefined padding
When packing integer(FP_SIZE) arrays into real(FP_COMM) buffers, an odd number of int32 values leaves padding bytes undefined in the last double. This caused roundtrip test failures on gcc-13 where the padding differed between pack cycles. Also fixes Intel 2025 segfault in expand by using array(:) = transfer(..., size=size(array)) to prevent allocatable reallocation.
1 parent 1cac954 commit 18a2628

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fitpack_core.F90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18360,6 +18360,8 @@ pure subroutine FP_REAL_COMM_PACK_1D(array, buffer)
1836018360
integer(FP_SIZE) :: bnd(2), ndoubles
1836118361
integer(FP_SIZE), parameter :: header = 1
1836218362

18363+
buffer(:) = 0.0_FP_COMM
18364+
1836318365
if (allocated(array)) then
1836418366
bnd = [lbound(array, 1, FP_SIZE), ubound(array, 1, FP_SIZE)]
1836518367
else
@@ -18382,6 +18384,8 @@ pure subroutine FP_REAL_COMM_PACK_2D(array, buffer)
1838218384
integer(FP_SIZE) :: bnd(2, 2), ndoubles
1838318385
integer(FP_SIZE), parameter :: header = 2
1838418386

18387+
buffer(:) = 0.0_FP_COMM
18388+
1838518389
if (allocated(array)) then
1838618390
bnd(1, 1) = lbound(array, 1, FP_SIZE)
1838718391
bnd(2, 1) = ubound(array, 1, FP_SIZE)
@@ -18407,6 +18411,8 @@ pure subroutine FP_REAL_COMM_PACK_3D(array, buffer)
1840718411
integer(FP_SIZE) :: bnd(2, 3), ndoubles
1840818412
integer(FP_SIZE), parameter :: header = 3
1840918413

18414+
buffer(:) = 0.0_FP_COMM
18415+
1841018416
if (allocated(array)) then
1841118417
bnd(1, 1) = lbound(array, 1, FP_SIZE)
1841218418
bnd(2, 1) = ubound(array, 1, FP_SIZE)
@@ -18434,6 +18440,9 @@ pure subroutine FP_SIZE_COMM_PACK_1D(array, buffer)
1843418440
integer(FP_SIZE) :: bnd(2), ndoubles
1843518441
integer(FP_SIZE), parameter :: header = 1
1843618442

18443+
! Zero buffer to avoid undefined padding when int32 count is odd
18444+
buffer(:) = 0.0_FP_COMM
18445+
1843718446
if (allocated(array)) then
1843818447
bnd = [lbound(array, 1, FP_SIZE), ubound(array, 1, FP_SIZE)]
1843918448
else

0 commit comments

Comments
 (0)