Nvfortran: Possible bug in character array transpose for initialization (original) (raw)

September 13, 2024, 11:46am 1

Hello,

I may have found a bug i character 2D array initialization, when transpose is involved.

character(len=2) :: foo(3,2) = transpose(reshape( &
    ([character(len=2) :: "X", "m", "Y", "m", "Z", "m" ]), &
    (/ size(foo, 2), size(foo, 1) /)))

integer :: bar(3,2) = transpose(reshape( &
    ([1, 2, 3, 4, 5, 6]), &
    (/ size(bar, 2), size(bar, 1) /)))

character(len=2) :: baz(2,3) = reshape( &
    ([character(len=2) :: "X", "m", "Y", "m", "Z", "m" ]), &
    (/ size(baz, 1), size(baz, 2) /))

END

gives me the error message
NVFORTRAN-S-0146-Expression must be character type (t.f90: 1)
NVFORTRAN-S-0146-Expression must be character type (t.f90: 1)
NVFORTRAN-S-0066-Too few data constants in initialization statement (t.f90: 1)
for the initialization of foo, while the seemingly equivalent integer initialization for bar works as expected. Using only the reshape without the transpose, as in baz, works as well. According to my understanding the transpose should be working also for the initialization of character arrays.

Regards,
Manuel

Thanks Manuel. I filed this one as TPR #36499.

Similar to your other post, engineering may defer this one given it works correctly with our development flang based compiler.

Hi Manuel,

FYI, engineering just let me know that they were able to get TPR #36499 fixed in nvfortran version 25.5.

-Mat