mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 21:40:12 +00:00
c82f5c0ce5
This patch fixes a "set but not used" warning in setjmp/jmpbug.c. A variable is used only to store the result of alloca. A cast to void is added to avoid the warning, and the variable is made volatile to ensure the call to alloca isn't optimized away for being unused. Tested for x86_64. * setjmp/jmpbug.c (test): Make foo volatile and cast it to void.
42 lines
513 B
C
42 lines
513 B
C
/* setjmp vs alloca test case. Exercised bug on sparc. */
|
|
|
|
#include <stdio.h>
|
|
#include <setjmp.h>
|
|
#include <alloca.h>
|
|
|
|
static void
|
|
sub5 (jmp_buf buf)
|
|
{
|
|
longjmp (buf, 1);
|
|
}
|
|
|
|
static void
|
|
test (int x)
|
|
{
|
|
jmp_buf buf;
|
|
char *volatile foo;
|
|
int arr[100];
|
|
|
|
arr[77] = x;
|
|
if (setjmp (buf))
|
|
{
|
|
printf ("made it ok; %d\n", arr[77]);
|
|
return;
|
|
}
|
|
|
|
foo = (char *) alloca (128);
|
|
(void) foo;
|
|
sub5 (buf);
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int i;
|
|
|
|
for (i = 123; i < 345; ++i)
|
|
test (i);
|
|
|
|
return 0;
|
|
}
|