FMS icon indicating copy to clipboard operation
FMS copied to clipboard

`test_diag_update_manager`: wrong datatype is set with `-fdefault-real-8`

Open foxtran opened this issue 2 months ago • 0 comments

Describe the bug

Here, https://github.com/NOAA-GFDL/FMS/blob/f13435f7a23f24d9eebcf01ca520cd67851b087b/test_fms/diag_manager/test_diag_update_buffer.F90#L186 missvalue gets FP value of default real kind. missvalue has a constrain on type which can be only integer(8) or real(4). So, once one uses default real kind as real(8), the data with wrong length (8 bytes) is copied into missvalue which is 4 bytes long (once it is real), and, then, extra 4 bytes are written out of bounds.

Such errors can be easily detected with AddressSanitizer (ASan) and, actually, detected in this way.

To Reproduce Enable ASan in CI.

Expected behavior No ASan error

System Environment CI of libFMS; FFLAGS="-fsanitize=address", LDFLAGS="-fsanitize=address"

foxtran avatar Dec 10 '25 14:12 foxtran