This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR54599 (4/n) FIx issues found by Coverity scann
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Mon, 17 Sep 2012 11:53:21 +0200
- Subject: Re: [Patch, Fortran] PR54599 (4/n) FIx issues found by Coverity scann
- References: <5056D59E.7070303@net-b.de>
On 17/09/2012 09:47, Tobias Burnus wrote:
> This patch fixes some of the issues collected in the PR.
>
>
> Some remarks to the changed in the attached patch:
>
>
> - gcc_assert (*format++ == '$');
>
> That code gets executed when
> "some error message with value %d for string %s"
> gets translated into
> "some error message for string %2$s with value %1$d"
>
> And without the ++ gfortran doesn't skip over the $ sign.
>
>
> + gcc_assert (derived1 && derived2);
> One of the many places where we first check for non-NULL - and then
> dereference the pointer unconditionally.
>
>
> - && ref->u.ar.as->lower && ref->u.ar.as->upper)
>
> "lower" is an array of pointers but not a pointer itself - thus, "lower"
> is always != NULL. Ditto for upper.
>
>
>
> - break;
> + continue;
>
> It makes sense to walk through the loop more than once ;-)
>
> + size = int_size_in_bytes (type);
> + gcc_assert (size >= 0);
>
> The function returns a HOST_WIDE_INT or -1 if it doesn't fit into that
> signed variable. To silence the warning, I now check the result and
> added an assert.
>
>
> Build and regtested on x86-64-linux.
> OK for the trunk?
>
> Tobias
OK