https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110360
David Edelsohn <dje at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dje at gcc dot gnu.org
--- Comment #25 from David Edelsohn <dje at gcc dot gnu.org> ---
The problem on big endian systems is that GFortran is passing the character
with the wrong padding.
I have changed val() to print both c and x, and not halt.
subroutine val (x, c)
character(kind=1), intent(in) :: x ! control: pass by reference
character(kind=1), value :: c
print *, "by value(kind=1): ", x
print *, "by value(kind=1): ", c
! if (c /= x) stop 1
c = "*"
if (c /= "*") stop 2
end
The output is:
by value(kind=1): B
by value(kind=1): B
by value(kind=1): A
by value(kind=1): A
by value(kind=1): A
by value(kind=1): <- c
by value(kind=1): A
by value(kind=1): <- c
by value(kind=1): A
by value(kind=1): <- c
by value(kind=1): 1
by value(kind=1): <- c
by value(kind=1): 1
by value(kind=1): <- c
The assembly language for the first few calls is
# call val ("B","B")
lwz 31,LC..5(2) LOAD ADDRESS of x
mr 3,31 COPY address to first parameter
li 6,1
li 5,1
lbzu 4,148(3) LOAD BYTE of c as second parameter
slwi 4,4,24 SHIFT c 24 bits
bl .val.4
# call val ("A",char(65))
mr 30,31 COPY ADDRESS of x
li 6,1
li 5,1
lbzu 4,152(30) LOAD BYTE of c as second parameter
slwi 4,4,24 SHIFT c 24 bits
mr 3,30 COPY address of first parameter
bl .val.4
# call val ("A",char(a))
li 6,1
li 5,1
li 4,65 <- c NOT SHIFTED
mr 3,30 <- x
bl .val.4
# call val ("A",mychar(65))
li 6,1
li 5,1
li 4,65 <- c NOT SHIFTED
mr 3,30 <- x
bl .val.4
# call val ("A",mychar(a))
li 6,1
li 5,1
li 4,65 <- c NOT SHIFTED
mr 3,30 <- x
bl .val.4
GFortran is not taking account of endianness for the layout of values in memory
compared to constants loaded into registers. This isn't an ABI issue of the
target, this is a memory layout and register layout issue of GFortran.
Let me know if you need more information or tests.