From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id E6A013858C55 for ; Thu, 13 Oct 2022 22:31:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E6A013858C55 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102e.google.com with SMTP id h12so3309081pjk.0 for ; Thu, 13 Oct 2022 15:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=obl/QQwTfaQ8zC76iSOfNDbVkqs8PB2CYuv5RPI1QgE=; b=edGY4aLsoAEjSw0ddp1UdUx3u0t1ECSPZGdOYO6ZpHG4OZyKXUWCLEiuEIYUF04WrG IpLgIqHaGvIogA6HY5uPICm5IO0hzc7HAd+wYtrg3ZsV7J8JU/VSEwdhEgD/l7QOVBE3 r2IBMTQCs0xR8YsmOpsxfp9KSUl7m9Q0GMBEPChqEwPdGK7pohJvnRsVDmlk+uyffPZe cAA5ZhIrb2kBk5pgkcw5qhd9CxASgbykTI8ZXWcHq8PUxGHkUT6HGtYVtVWb4V8MJFdz rdAL7HcKG+tSD7ZQBgZqnZNat6nWNHHNQpFzpCCrncvrmkIsgLeHbBica9NhMPRyMhu7 cE3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=obl/QQwTfaQ8zC76iSOfNDbVkqs8PB2CYuv5RPI1QgE=; b=7hGzwcfg8zRzv0RqrIzRKu7z5F21ocz7dbhMKeNuMPAi/X59c1i4fb4jx9Fzl3/B+s 3RNGRatoEFrw9k9kbvYbJ1mwNHYbDX2odKhJJVmCicNovbwlxShuiiPudi+yU5VZJ9ZD jC+ef0o8Vcr/ZlxbA3tIUYXioHQlBGkQl5PzI/gDb4FVdS1fOW5Xo1GyI5a/G27cVG72 86MEHOTMZ/XR52KM79xEzAJezl+lVAMtrNMALG2DRuSh3OgCsddZSz2ggMNdhonKcjeu Q2qeV1JzHOwSz8YZG1xTwP+Kk8w0bR0q4Gkgcdi0DqKjEphvvNHUMIMkaR5ZICjOcZS7 v9cg== X-Gm-Message-State: ACrzQf0T+swQ/aDfYp8IgfVF6vO3vQ96faPAhorQx1KgIsA7Xycr+92u 9zx1TxNE+TpiBbDXrzq1M7A= X-Google-Smtp-Source: AMsMyM4wABzTyujbDxahm/VLGeEegvivBhhRUWmCeWu4H2h8N1PCWzuraNwk52AnUmLt4XWb+u9raA== X-Received: by 2002:a17:902:ee82:b0:185:3a76:d39c with SMTP id a2-20020a170902ee8200b001853a76d39cmr1875082pld.166.1665700280655; Thu, 13 Oct 2022 15:31:20 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id t14-20020a17090a3e4e00b0020ad86f4c54sm258114pjm.16.2022.10.13.15.31.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 15:31:20 -0700 (PDT) Message-ID: Date: Thu, 13 Oct 2022 16:31:19 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] Fix bogus -Wstringop-overflow warning Content-Language: en-US To: Eric Botcazou , gcc-patches@gcc.gnu.org References: <3194055.aeNJFYEL58@fomalhaut> From: Jeff Law In-Reply-To: <3194055.aeNJFYEL58@fomalhaut> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/13/22 06:06, Eric Botcazou via Gcc-patches wrote: > Hi, > > if you compile the attached testcase with -O2 -fno-inline -Wall, you get: > > In function 'process_array3': > cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [- > Wstringop-overflow=] > cc1: note: referencing argument 1 of type 'char[4]' > t.c:6:6: note: in a call to function 'process_array4' > 6 | void process_array4 (char a[4], int n) > | ^~~~~~~~~~~~~~ > cc1: warning: 'process_array4' accessing 4 bytes in a region of size 3 [- > Wstringop-overflow=] > cc1: note: referencing argument 1 of type 'char[4]' > t.c:6:6: note: in a call to function 'process_array4' > > That's because the ICF IPA pass has identified the two functions and turned > process_array3 into a wrapper of process_array4. This looks sensible to me > given that the only difference between them is an "access" attribute on their > type describing the access size of the parameter and the "access" attribute > does not affect type identity (struct attribute_spec.affects_type_identity). > > Hence the proposed fix, tested on x86-64/Linux, OK for the mainline? > > > 2022-10-13 Eric Botcazou > > * gimple-ssa-warn-access.cc (pass_waccess::check_call): Return > early for calls made from thunks. > > > 2022-10-13 Eric Botcazou > > * gcc.dg/Wstringop-overflow-89.c: New test. Not a fan as it could potentially hide a real issue, but I don't really have a better solution.  I pondered suggesting "access" affect type identity, but the cases where that's really important are probably better handled by the "fn spec" attribute, leaving "access" strictly impacting diagnostics. OK jeff