From patchwork Thu Sep 15 20:23:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp444035wrt; Thu, 15 Sep 2022 13:24:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cP3z21RPrDYQsmw1r70i6i261cKou38wfBmxtaMk2RzcA5Q3+7YZEHSdW3yo8xoaOtQbt X-Received: by 2002:aa7:cc8a:0:b0:446:7668:2969 with SMTP id p10-20020aa7cc8a000000b0044676682969mr1323965edt.206.1663273452464; Thu, 15 Sep 2022 13:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663273452; cv=none; d=google.com; s=arc-20160816; b=qREvl6Tw7ddMllr16V9yzmOIyQyYE+wbYjP8f/mXnEZ2cLIvTP5q171veTLRY9w1aZ t4E14VKm2X4OWiJpBpzyIbpGTuAfR7Efd5uSRIfT+d2+EcjAMBiFzuitnEUKd2ClS8XU ZX08wyv/NGLI6+w0LLQeTwDIzTuWQsMqO/2in2YTDCv/L09+b+zyWgFby5PNHOV2gv8y zYxc3b1ov9RfGazUxSKM5UkJHKyIhHrsz3d+BZq17vQJXsxgkKl71EFvkKLA2lRFkiHw pKCpT+8NgUFRsCfPLiwTOxBB64ox6cri9/PlM1dn3cHPfA20vFSA9mpJz2TIjzXGk80c uL8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=xiL5rUq28/W1dujJB+uqtTc1SdZKTdsYzfQP+TVo/sE=; b=zWKpkKLbB6r0kp1Aj1JVR3+RmxzucBFh+Xu66M1IcJf2HbrFalDwOjnswYer1mhoAm vBpUJL6q4U+XaZ+uZE2DTkh/mskEKAWwJ6+D0eeAglsGx4HhBPr2iYGtyPrGg2Btv8dM nTv+PbGa0Eub3xFUz4S88pqX9/B8+SVj2iL8npNrrUkxwoday4vgECW8WJhj3ooWk2VH Lay1w7fM3IHN8YLArC1zszcpPkvsNQgQMA3OTvwoCbH5hER7PBzoahckYADSgtZD4Mml m+M8f+1NEJoaF3lRqkyOVBJ4H1B2fu+HPMbpzGRdKvk4a6g1fD46MaDgJyYmvsvohC6g RBqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s4y3EVzg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cr20-20020a170906d55400b0077e156d8e07si9128731ejc.828.2022.09.15.13.24.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 13:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s4y3EVzg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FAAF382892A for ; Thu, 15 Sep 2022 20:24:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FAAF382892A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663273451; bh=xiL5rUq28/W1dujJB+uqtTc1SdZKTdsYzfQP+TVo/sE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=s4y3EVzg/tb23PX2IO2FyO3ZeuNyVz7CR54l/zH1E9mX3KVtazZTqb0m+oD+AkQ/5 mXyz/GzkLDDjWz+8Efx+ac4OAWmix09bk4RF40D060q1fHNXjZCyR1a9blppoYh3u1 5M/YTp0LU8eoQ7ARXzcgDz8jJKlY2KQ6CknThljM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 27AFE3839DCE; Thu, 15 Sep 2022 20:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27AFE3839DCE X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.80.54] ([93.207.80.54]) by web-mail.gmx.net (3c-app-gmx-bs69.server.lan [172.19.170.214]) (via HTTP); Thu, 15 Sep 2022 22:23:26 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: error recovery for bad deferred character length assignment [PR104314] Date: Thu, 15 Sep 2022 22:23:26 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:F347IAs75jRfiFpyQihgAThBmx6ondvj7LFo1a9fJsM6mie3ML47k79yNyLGJZZHBpFxa ed0iB0I5ftz3pnc5uRRo5C+1zHd79iQ8huduLOK7skBfLxtk1jR00sUvSQg/K/jCBRXJYtHImUIf YsLgx3b02ro20qmKMeiKpA2Ne6BvS1JZ/RRM3CdnNfQB8g5JfPYPDlB14+sEYh6AWTPECFH/VmRk 5zjlJbO960iMawlO/3gy1F1d/ClPhp9N9CZl5m1dFzv8v9ikYF7sB6vLJPFO2zotXI0OyBkpZPPF UI= X-UI-Out-Filterresults: notjunk:1;V03:K0:AYc2suD2bhA=:BPvjUyfXakT+HxlGzBqULF R7GNXdwemKTI/QKrXJSSKUGzgYdofxJ/vp2FLNzSj06UMOCozddGVQyJUv9OgdOt0OxnkRfT9 xbiCnTdVqaNOdQ/QT96Od7YmBw5g5POS4vxUCxpPirl0VON38cQwBBzzDQeRJBUMh1+/E5J6c PAkGWcd0Pqxa3MKhdT4z+22GT0u0HarSc6Wjuqaj9kyz3C8TchUMzomeKl0fokRdfLonGCbKO qH85EO9OOKvqKBdnNaW6uALcnpNqxGNZbnMKTqV7CmkwFR1jl1hKpYHmNi8FkShYvGhf75Ymc HOy/0xrDfmeTSKAsS+rw3v5nndTcslblJwhZECV62z9ovOsh6J0d2hFGt3rIgnVnMdSQp+1/y 83cmLfPSFDoMbyjFjNWek2vteGkootFGeUKky2QeqFWMmxfve83os/QTQQMq1jVu16sJ8Lb43 BchFam3ThhRkll9w+mESuoBIIELkyzAlI434CFHOCFDIwmkv3/j4Ds/mB8nOXn9G+4GKoadSd mGIDGy0Ot8QbjHYBCUkf1Qj93kdHWlE5IK5Lmd9PT/BPfcffXTfBmrhTmvwcJkSSFzXS2J1SU b9WFLkYvy5dhczVQYHUgh5PX/7pzbWc3TtmbKEyVIgyGpHnnJDj4qT6m8QyCQlQ1zZ4VMtiGS 7depbwgKapGrdEBVzk9aLUjzTvuAcbwUItl7bnpy2JiNJ0qeit4nkWbZI8i7RIfv99Gi79tSt DVYIfZ7WDC0OZf4ebhnDAna49zJdbRoazCZvby6nvFGgBj3kRGdmOrytAE9zzlv7kpVEu/kI+ Otue6I/ X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744068623664812305?= X-GMAIL-MSGID: =?utf-8?q?1744068623664812305?= Dear all, the attached obvious patch fixes an ICE on a NULL pointer dereference. We didn't properly check that the types of expressions are character before referencing the length. The issue was originally investigated by Steve, so I made him co-author. Regtested on x86_64-pc-linux-gnu and pushed to mainline as commit r13-2690-g7bd4deb2a7c1394550610ab27507d1ed2af817c2 Thanks, Harald From 7bd4deb2a7c1394550610ab27507d1ed2af817c2 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 15 Sep 2022 22:06:53 +0200 Subject: [PATCH] Fortran: error recovery for bad deferred character length assignment [PR104314] gcc/fortran/ChangeLog: PR fortran/104314 * resolve.cc (deferred_op_assign): Do not try to generate temporary for deferred character length assignment if types do not agree. gcc/testsuite/ChangeLog: PR fortran/104314 * gfortran.dg/pr104314.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/resolve.cc | 1 + gcc/testsuite/gfortran.dg/pr104314.f90 | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr104314.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index ca114750f65..ae7ebb624e4 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -11803,6 +11803,7 @@ deferred_op_assign (gfc_code **code, gfc_namespace *ns) if (!((*code)->expr1->ts.type == BT_CHARACTER && (*code)->expr1->ts.deferred && (*code)->expr1->rank + && (*code)->expr2->ts.type == BT_CHARACTER && (*code)->expr2->expr_type == EXPR_OP)) return false; diff --git a/gcc/testsuite/gfortran.dg/pr104314.f90 b/gcc/testsuite/gfortran.dg/pr104314.f90 new file mode 100644 index 00000000000..510ded0b164 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104314.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/104314 - ICE in deferred_op_assign +! Contributed by G.Steinmetz + +program p + character(:), allocatable :: c(:) + c = ['123'] + c = c == c ! { dg-error "Cannot convert" } +end -- 2.35.3