Bug 45629 - libgfortran/io/list_read.c:1872:10: warning: variable 'elem' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered]
Summary: libgfortran/io/list_read.c:1872:10: warning: variable 'elem' might be clobber...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Janne Blomqvist
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-10 07:41 UTC by Tobias Burnus
Modified: 2010-11-04 19:40 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-11-01 07:28:21


Attachments
Preliminary patch (4.35 KB, patch)
2010-10-16 22:07 UTC, Janne Blomqvist
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-09-10 07:41:36 UTC
At least on MinGW64 (as reported by nightstrike), the following warning is printed when compiling libgfortran:

libgfortran/io/list_read.c:1872:10: warning: variable 'elem' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered]

If one looks at the source, one sees:

  1869	list_formatted_read (st_parameter_dt *dtp, bt type, void *p, int kind,
  1870			     size_t size, size_t nelems)
  1871	{
  1872	  size_t elem;
[...]
  1880	  for (elem = 0; elem < nelems; elem++)
  1881	    {
  1882	      dtp->u.p.item_count++;
  1883	      list_formatted_read_scalar (dtp, type, tmp + stride*elem, kind, size);


with
  1704	list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
  1710	  jmp_buf eof_jump;

However, I do not see how "elem" itself gets clobbered - thus the warning looks bogus to me, but I have only glanced at the code.
Comment 1 Janne Blomqvist 2010-10-16 22:07:19 UTC
Created attachment 22068 [details]
Preliminary patch

Preliminary patch for getting rid of setjmp/longjmp, instead using an errno-style flag variable.
Comment 2 Janne Blomqvist 2010-10-16 22:10:19 UTC
(In reply to comment #1)
> Created attachment 22068 [details]
> Preliminary patch
> 
> Preliminary patch for getting rid of setjmp/longjmp, instead using an
> errno-style flag variable.

... preliminary, as in fails a few testcases. Anyways, I'm not sure when I'll have time to finish it, but if anyone wants to lend a hand. Not that it's any particularly high priority either.
Comment 3 Jerry DeLisle 2010-10-16 23:22:19 UTC
I will look it over when I have a few other bugs out of the way.
Comment 4 Janne Blomqvist 2010-11-01 07:28:21 UTC
Scratch that previous patch. It turned out to not be such a good idea after all, I'm working on a better approach.
Comment 5 Janne Blomqvist 2010-11-01 23:32:59 UTC
Patch here: http://gcc.gnu.org/ml/gcc-patches/2010-11/msg00096.html
Comment 6 Janne Blomqvist 2010-11-02 12:56:44 UTC
Author: jb
Date: Tue Nov  2 12:56:38 2010
New Revision: 166180

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166180
Log:
PR 45629 Remove usage of setjmp/longjmp

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/io.h
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/transfer.c
Comment 7 Janne Blomqvist 2010-11-04 19:40:08 UTC
Closing as fixed.