From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 650DE3857007; Wed, 1 Jul 2020 11:39:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 650DE3857007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593603565; bh=ZVlG8sQ1PLAn0GOVjZL8t5G6cq41NFDF5srHumBndoA=; h=From:To:Subject:Date:From; b=PT7OVmmQr7VNYnFn3T6APO6t3/MKhWDqwqPA37Ye6AbWLp6KZCRMBaJ56nJdYeVv2 xG9rYSmSSzIxlQowSQbZM9b0lVs3rjfXH23V6nBb4wgCWqvHUSBFl32WwpdPmAfes0 eJXif/TLmClfB3HQh+DvO07GLqqgJ2t9EQ2Td26o= From: "martin.schlipf at damnthespam dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/96018] New: Optimization issue with external HDF5 library Date: Wed, 01 Jul 2020 11:39:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: martin.schlipf at damnthespam dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 11:39:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96018 Bug ID: 96018 Summary: Optimization issue with external HDF5 library Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: martin.schlipf at damnthespam dot com Target Milestone: --- Created attachment 48817 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D48817&action=3Dedit Minimal example to demonstrate the issue. On a clean Ubuntu 20.04 with the following setup sudo apt-get update sudo apt-get install gfortran-10 sudo apt-get install libhdf5-dev the attached code produces an error when compiled with optimization gfortran-10 -O2 hdf5_bug.f90 -I/usr/include/hdf5/serial/ -L/usr/lib/x86_64-linux-gnu/ -lhdf5_serial_fortran As far as I can tell, the reason this appears is that the compiler fails to recognize that the function call in line 98 has side effects and optimizes = it away. If you check the status of the error code, the issue disappears. Strangely, the exact same sequence of calls with a 2d array instead of a 3d= one works fine.=