From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0D7B385734E; Mon, 15 May 2023 14:00:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0D7B385734E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684159214; bh=qoc+FYeIX3GpDEJtGVsaYrSUCNWb8ylHzy68TwVgfC8=; h=From:To:Subject:Date:From; b=xApv7ucjTgQ2z9TlKyZEm8fxs2kWxa0EA8L37TnhSWTiV7499qS3ZjVikzx4m7WHN qiB1fDdrGBsG+5H7aVDkKQVcdSG5AwtcCpKLH7KM5vPRs6+CEODzCuRgs0GDPlRq/w IYva8KNnuHA2iOX9ncxiLWs2YkJXkwLfBiGMwMz0= From: "brtnfld at hdfgroup dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109861] New: Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault. Date: Mon, 15 May 2023 14:00:14 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: brtnfld at hdfgroup dot org 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109861 Bug ID: 109861 Summary: Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault. Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: brtnfld at hdfgroup dot org Target Milestone: --- Created attachment 55085 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55085&action=3Dedit Fortran/C/Makfile. Changing the optimization level in the makefile reproduc= es the behaviour. For a TYPE(C_PTR), INTENT(OUT), buf, which is being passed through a Fortran subroutine to get the value set in a C function, an optimization of >=3D -O1 gives the warning "used uninitialized [-Wuninitialized]" and then the progr= am Segmentation faults - invalid memory reference. It works for gfortran 12 but fails for gfortran 13 and 14. It works if the INTENT is INOUT.=