This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix -Wshadow=local and undefined behavior in fortran/primary.c
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Thu, 3 Oct 2019 09:04:52 -0700
- Subject: Re: [PATCH] Fix -Wshadow=local and undefined behavior in fortran/primary.c
- References: <VI1PR03MB452854D41D0D14FE97A3E19BE49F0@VI1PR03MB4528.eurprd03.prod.outlook.com>
- Reply-to: sgk at troutmask dot apl dot washington dot edu
On Thu, Oct 03, 2019 at 03:19:15PM +0000, Bernd Edlinger wrote:
>
> This fixes two -Wshadow=local warnings, and a undefined behavior that is
> used in the loop termination logic here:
>
> for (p = c - 1; p >= buffer; p--)
> {
> if (*p == '.')
> continue;
>
> In order to terminate the loop p is decremented until it points
> to buffer-1 (buffer is alloca'd, so that is undefined behavior.
>
> I changed that loop to
> for (p = c; p > buffer;)
> {
> p--;
> if (*p == '.')
> continue;
>
> There are a lot more -Wshadow=local warnings in the fortran subtree,
> but they are not bug fixes, so I plan to commit them in the
> following days, as obvious.
>
>
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
>
Yes.
--
Steve