From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 43C923861916; Wed, 1 Jul 2020 19:31:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43C923861916 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593631875; bh=eODeHKQB20NtXugFF9pYUBB+UKpasFctR+R9EGU+dL4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eFsDK5t68otOrnbl3R6G2IWvMYsEBqlwfqNR22mlMw6RSli92c5lnnKUBit4SZcde eND7sHXv449T45b2voD9oQRv+TxjOp2tUVs/47gy7f/ZbwTJda6haHzzKUUKcSofgK fNU0ebV7iWpaa4Nr11ds7iXL1MYgtzLUBh6aGfHo= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/96018] Optimization issue with external HDF5 library Date: Wed, 01 Jul 2020 19:31:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jul 2020 19:31:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96018 --- Comment #5 from anlauf at gcc dot gnu.org --- (In reply to martin.schlipf from comment #4) > Finally, I reproduced it with gfortran 9.3.0 + hdf 1.12.0 and gfortran 10= .0 > + hdf 1.10.4. With older versions of gfortran 7.3.0 it does not appear. Workarounds: - compile with -O0, not sure why this makes a difference - or replace in write_real_array_nd: real, intent(in) :: array(*) by real :: array(*) I'd recommend to additionally replace in write_complex_array_3d ierr =3D write_real_array_4d(locid, dataset_name, ptr) by ierr =3D write_real_array_4d(locid, dataset_name, & reshape (transfer(array,[1.0]),[2, shape(array)])) The latter is IMO much cleaner Fortran. There might by a bug in gfortran with the way you use c_f_pointer and assumed-size, which generates wrong code for argument packing, or there is a bug elsewhere which may corrupt data subtly.=