This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libgfortran] PR 41219 Silence uninitialized variable warning
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Martin Jambor <mjambor at suse dot cz>
- Date: Sun, 6 Sep 2009 14:59:18 +0200
- Subject: Re: [Patch, libgfortran] PR 41219 Silence uninitialized variable warning
- References: <7b446c2e0909060556j1bc332f1ue2f9d1b0832e40dc@mail.gmail.com>
On Sun, Sep 6, 2009 at 2:56 PM, Janne
Blomqvist<blomqvist.janne@gmail.com> wrote:
> Hi,
>
> the patch below fixes the "use of uninitialized variable" warning in
> unix.c. It's a spurious warning as the fstat() call will initialize
> the stat struct, but gcc can't see it.
Huh, that looks odd. I bet this is SRA at work.
Richard.
> Ok for trunk?
>
> 2009-09-06 ?Janne Blomqvist ?<jb@gcc.gnu.org>
>
> ? ? ? ?PR libfortran/39667
> ? ? ? ?* io/unix.c (fd_to_stream): Silence uninitialized warning.
>
>
> diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
> index 4ecba3a..e26f281 100644
> --- a/libgfortran/io/unix.c
> +++ b/libgfortran/io/unix.c
> @@ -759,6 +759,10 @@ fd_to_stream (int fd, int prot)
> ? s->logical_offset = 0;
> ? s->prot = prot;
>
> + ?/* Silence compiler warnings about using unitialized variables. ?*/
> + ?statbuf.st_mode = 0;
> + ?statbuf.st_size = 0;
> +
> ? /* Get the current length of the file. */
>
> ? fstat (fd, &statbuf);
>
>
> --
> Janne Blomqvist
>