public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Martin Sebor <msebor@gmail.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] correct formatting of function pointers in -Warray-bounds (PR 101601)
Date: Wed, 28 Jul 2021 08:08:12 -0600	[thread overview]
Message-ID: <fc560453-a234-feb5-30a6-f810ef0f324e@gmail.com> (raw)
In-Reply-To: <f6a82019-b699-a12a-f49d-e9081666f345@gmail.com>



On 7/27/2021 2:45 PM, Martin Sebor via Gcc-patches wrote:
> When mentioning the type of the accessed object -Warray-bounds
> treats singleton objects as arrays of one element for simplicity.
> But because the code doesn't distinguish between function and
> object pointers, a warning for an out-of-bounds index into
> a singleton function pointer object attempts to create an array
> of one function.  Since arrays of functions are invalid,
> the helper function the code calls fails with an error issued
> to the user.
>
> To avoid this the attached patch avoids this singleton-to-array
> shortcut for function pointers.  Tested on x86_64-linux.
>
> Martin
>
>
> gcc-101601.diff
>
> PR middle-end/101601 - [12 Regression] -Warray-bounds triggers error: arrays of functions are not meaningful
>
> 	PR middle-end/101601
>
> gcc/ChangeLog:
>
> 	* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Remove
> 	a pointless test.
> 	Handle pointers to functions.
>
> gcc/testsuite/ChangeLog:
>
> 	* g++.dg/warn/Warray-bounds-25.C: New test.
> 	* gcc.dg/Warray-bounds-85.c: New test.
OK
jeff


      reply	other threads:[~2021-07-28 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 20:45 Martin Sebor
2021-07-28 14:08 ` Jeff Law [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc560453-a234-feb5-30a6-f810ef0f324e@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).