From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 906393861011 for ; Thu, 7 Jan 2021 23:24:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 906393861011 Received: by mail-pj1-x1030.google.com with SMTP id j13so5093469pjz.3 for ; Thu, 07 Jan 2021 15:24:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kTAhAipTbfl7qFqqzU54Y4/ZzB1Y3MVNeRHc63yMGgU=; b=Xb7rR7nlYyUuhLShKwZw0tADyihz0OW/tY1PoCXZM4yrn7jIRF3zYe+QzWhg7Q+p2q QbCpUaLaNKKM+JMholqrm5ZZFRialy4ElP4KSNU9WRjG4IZTtm63mLJEsly2kYYZZJH5 uXalekPnInHcF7K6cMR8Ha9a2Cr4xA6RkryzarXpvTBeky3IR6kWrrmjLyZoUbqIEdYh gzbcMlNkuGr0Y4UbSugU5sKuk49Lev6RlGJFxdBwHA/FTJSZfUM/7nz25DF58h8Bkyi9 7uEdzHT9DrRGSo0bZdc/udibHOCSOf031dTiWN249aJC/xDBV5g8/dlhOSKTFzOHEvh1 nOYQ== X-Gm-Message-State: AOAM53305zdsKc4auCWPdRWpDnatFE6bxyks0ieKD1M/RNLHVrQjCKAn y0BSjfyBXkP+99k9kwgOPyughpALpDY= X-Google-Smtp-Source: ABdhPJx4Lbi27JnoJSvqvALWsLenpH2YWu8+8ibfL0NxcbpPZNDwjBWQv40Bqdv8otsO3M3k01IV6g== X-Received: by 2002:a17:90a:cb84:: with SMTP id a4mr831699pju.50.1610061896440; Thu, 07 Jan 2021 15:24:56 -0800 (PST) Received: from [192.168.0.41] (75-166-96-128.hlrn.qwest.net. [75.166.96.128]) by smtp.gmail.com with ESMTPSA id s7sm3060250pgi.69.2021.01.07.15.24.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Jan 2021 15:24:55 -0800 (PST) Subject: Re: [committed] fix another ICE in MEM_REF formatting (PR 98578) To: Jakub Jelinek Cc: gcc-patches References: <12069778-e6af-6fb9-13d4-a3c555c70a29@gmail.com> <20210107213702.GQ725145@tucnak> From: Martin Sebor Message-ID: <254f1837-334e-1ccb-ca8f-0bb25feefb61@gmail.com> Date: Thu, 7 Jan 2021 16:24:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20210107213702.GQ725145@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 07 Jan 2021 23:24:59 -0000 On 1/7/21 2:37 PM, Jakub Jelinek wrote: > On Thu, Jan 07, 2021 at 02:29:50PM -0700, Martin Sebor via Gcc-patches wrote: >> --- a/gcc/c-family/c-pretty-print.c >> +++ b/gcc/c-family/c-pretty-print.c >> @@ -1844,22 +1844,25 @@ print_mem_ref (c_pretty_printer *pp, tree e) >> } >> } >> >> - const tree access_type = TREE_TYPE (e); >> + tree access_type = TREE_TYPE (e); >> + if (TREE_CODE (access_type) == ARRAY_TYPE) >> + access_type = TREE_TYPE (access_type); >> tree arg_type = TREE_TYPE (TREE_TYPE (arg)); >> if (TREE_CODE (arg_type) == ARRAY_TYPE) >> arg_type = TREE_TYPE (arg_type); > > The array types can be multidimensional, are you sure you don't want > to use strip_array_types instead? Pretty sure. access_type is used to figure out the element index and residual byte offset into the argument, so that needs the size of the array. Both access_type and arg_type are then checked for compatibility, to decide if the type of the access needs to be included as a cast. So there again I think the outer array bounds need to be preserved. There are a few simple tests involving multidimensional VLAs but a more involved example I just tried triggers another ICE, this time in gimple_canonical_types_compatible_p. Apparently the default invocation of the function doesn't like mixed arrays and scalars. So clearly there's a whole bounty of ICEs here and more to do. Martin