This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bugs in gcc
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Subject: Bugs in gcc
- From: Tim Bedding <tim at polyhedra dot com>
- Date: Wed, 13 Oct 1999 11:05:08 +-100
- Encoding: 89 TEXT
I am not sure whether this email got through to the list...
gcc version 2.95 19990728
DOS
I imagine that these problems are not platform specific
and do not depend on specific headers.
1) The output from compiling test.c with -O1 -Wall includes:
test.c:10: warning: argument 'x' might be clobbered by
'longjmp' or 'vfork'
According to my copy of the info documentation for gcc
(Node: Warning Options), this warning should not be produced
for -Wall only for -W.
Either the documentation or the implementation is incorrect.
I suggest the latter.
2) If test.c is compiled with -W, then the "clobbered"
warning is not produced. Running the test program yields:
hello3
hello2
after longjmp 3
This lack of a warning strikes me as incorrect. Even with no
optimisation, there is the potential for the wrong value of x (3)
as the output demonstrates.
I suggest that the warning should occur even with
optimisation turned off.
3) I think it should be possible to improve the heuristic
so that the "clobbered" warning is not generated in
certain cases.
For example, if x is not used by the second printf in
the delenn function, then I think that the warning
should not occur. The reason for this is that no damage
occurs even if x is incorrect. The value of x is not used.
Another possibility is that x is set before use:
if (setjmp(j))
{
x = 0;
printf("after longjmp %d\n",x);
return;
}
Once again, I think that in this case no warning should be issued
as the clobbering will not affect the running of the program.
test.c
#include <stdio.h>
#include <setjmp.h>
int lennier(int y)
{
return (y + 1);
}
void delenn(int x)
{
jmp_buf j;
printf("hello3\n");
if (setjmp(j))
{
printf("after longjmp %d\n",x);
return;
}
x = lennier(x);
printf("hello2\n");
x = lennier(x);
longjmp(j, 1);
}
int main()
{
delenn(1);
return 0;
}