From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A884D3857351; Tue, 18 Jul 2023 20:09:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A884D3857351 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689710994; bh=6SSXolKngplwcOURIy9/qCo/0O0Ln//DlGkmeXf0dow=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M50jYAe3k37LT80dHYR/aR4wmjG62mpeaOCgUZcLG20kqr2SSSP9qceGdD5ICrrMT Fb/eXXUGWcUNAFfjojCHLXjyMlO4+sWjcMfXNa+YuqzAm0aIioeuqRTSvWU2Aacyzd WAEBQjQ2dnqK2yR22O/uJ+t1za+tXZ0nrONLVUag= From: "dje at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug testsuite/110419] [14 regression] new test case gfortran.dg/value_9.f90 in r14-2050-gd130ae8499e0c6 fails Date: Tue, 18 Jul 2023 20:09:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: testsuite X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: testsuite-fail X-Bugzilla-Severity: normal X-Bugzilla-Who: dje at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cc cf_reconfirmed_on everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110419 David Edelsohn changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |dje at gcc dot gnu.org Last reconfirmed| |2023-07-18 Ever confirmed|0 |1 --- Comment #16 from David Edelsohn --- As I wrote in issue 110360, the bug appears to be the memory layout and pad= ding assumed by GFortran that does not take into account endianness. I have changed val() to print both c and x, and not halt. subroutine val (x, c) character(kind=3D1), intent(in) :: x ! control: pass by reference character(kind=3D1), value :: c print *, "by value(kind=3D1): ", x print *, "by value(kind=3D1): ", c ! if (c /=3D x) stop 1 c =3D "*" if (c /=3D "*") stop 2 end The output is: by value(kind=3D1): B by value(kind=3D1): B by value(kind=3D1): A by value(kind=3D1): A by value(kind=3D1): A by value(kind=3D1): <- c by value(kind=3D1): A by value(kind=3D1): <- c by value(kind=3D1): A by value(kind=3D1): <- c by value(kind=3D1): 1 by value(kind=3D1): <- c by value(kind=3D1): 1 by value(kind=3D1): <- 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 me= mory 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. On a big endian system, a character / byte is loaded at the LSB, but GFortr= an seems to be comparing it to a memory image with the character / byte stored= at the MSB, which would be correct for little endian. In some cases, GFortran= is shifting the value and in other cases it is not. GFortran does not seem to have a consistent view of the memory layout for characters / bytes loaded into a larger object.=