public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/24239]  New: spurious warning about clobbered variables w.r.t. longjmp
@ 2005-10-06 15:49 dvilleneuve at kronos dot com
  2005-10-09  3:46 ` [Bug middle-end/24239] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dvilleneuve at kronos dot com @ 2005-10-06 15:49 UTC (permalink / raw)
  To: gcc-bugs

The test for emitting a warning about "variables that might be clobbered by a
call to longjmp or vfork" is overly pessimistic (unless I miss something from
the C89/C99 standards).

In my opinion, the following code fragment should not get the warning, but it
does when compiled with `gcc -O -W':
<code>
#include <setjmp.h>

extern int f(void);
extern int g(int);
extern jmp_buf jb;

int f(void)
{
  int j;

  j = 0;
  if( !setjmp(jb) ) {
    g(j);
  }
  else {
    j = -1;
  }

  return j;
}
</code>

I have also other variants that get the warning without deserving it (IMO).

Here is one relevant paragraph from ISO 9899 7.13.2.1:

<C99-quote>All accessible objects have values, and all other components of the
abstract machine have state, as of the time the longjmp function was called,
except that the values of objects of automatic storage duration that are local
to the function containing the invocation of the corresponding setjmp macro
that do not have volatile-qualified type and have been changed between the
setjmp invocation and longjmp call are indeterminate.</C99-quote>

Feel free to contact me (I could try to contribute, at least for providing more
test programs).

Thanks for your great work!

PS: the warning code in is gcc/function.c, which is why I've guessed about the
component.


-- 
           Summary: spurious warning about clobbered variables w.r.t.
                    longjmp
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvilleneuve at kronos dot com
  GCC host triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24239


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/24239] spurious warning about clobbered variables w.r.t. longjmp
  2005-10-06 15:49 [Bug tree-optimization/24239] New: spurious warning about clobbered variables w.r.t. longjmp dvilleneuve at kronos dot com
@ 2005-10-09  3:46 ` pinskia at gcc dot gnu dot org
  2005-10-11 12:28 ` dvilleneuve at kronos dot com
  2005-11-26  7:54 ` gdr at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-09  3:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-09 03:46 -------
I think this is fixed on 4.0.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24239


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/24239] spurious warning about clobbered variables w.r.t. longjmp
  2005-10-06 15:49 [Bug tree-optimization/24239] New: spurious warning about clobbered variables w.r.t. longjmp dvilleneuve at kronos dot com
  2005-10-09  3:46 ` [Bug middle-end/24239] " pinskia at gcc dot gnu dot org
@ 2005-10-11 12:28 ` dvilleneuve at kronos dot com
  2005-11-26  7:54 ` gdr at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: dvilleneuve at kronos dot com @ 2005-10-11 12:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dvilleneuve at kronos dot com  2005-10-11 12:28 -------
Indeed, in gcc-4.0.1, the previous code chunk does not elicit a warning.
However, a slightly modified version still gets a warning (tested
on RHEL-4, with <gcc version 4.0.1 20050727 (Red Hat 4.0.1-4.EL4.2)>).

<c-code>
#include <setjmp.h>

extern int f(void);
extern int g(int);
extern jmp_buf jb;
extern int i;

int f(void)
{
  int j;

  if( i > 10 ) j = i;
  else j = i + 10;

  if( !setjmp(jb) ) {
    g(j);
  }
  else {
    j = -1;
  }

  return j;
}
</c-code>


-- 

dvilleneuve at kronos dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|3.4.4                       |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24239


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/24239] spurious warning about clobbered variables w.r.t. longjmp
  2005-10-06 15:49 [Bug tree-optimization/24239] New: spurious warning about clobbered variables w.r.t. longjmp dvilleneuve at kronos dot com
  2005-10-09  3:46 ` [Bug middle-end/24239] " pinskia at gcc dot gnu dot org
  2005-10-11 12:28 ` dvilleneuve at kronos dot com
@ 2005-11-26  7:54 ` gdr at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-26  7:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from gdr at gcc dot gnu dot org  2005-11-26 07:54 -------
(In reply to comment #2)
> Indeed, in gcc-4.0.1, the previous code chunk does not elicit a warning.
> However, a slightly modified version still gets a warning (tested
> on RHEL-4, with <gcc version 4.0.1 20050727 (Red Hat 4.0.1-4.EL4.2)>).

I can reproduce the behaviourwith mainline GCC (4.2.x)


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdr at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-26 07:54:49
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24239


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-11-26  7:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-06 15:49 [Bug tree-optimization/24239] New: spurious warning about clobbered variables w.r.t. longjmp dvilleneuve at kronos dot com
2005-10-09  3:46 ` [Bug middle-end/24239] " pinskia at gcc dot gnu dot org
2005-10-11 12:28 ` dvilleneuve at kronos dot com
2005-11-26  7:54 ` gdr at gcc dot gnu dot org

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).