A
Anargyros L. Papadopoulos
int do_sth(int);
int fun_1(int *val, int i = 0)
{
static int *s[3];
if (val && i >= 0 && i < 3) {
s = val;
return 1;
} else {
if (s[0])
do_sth(*s[0]);
return 0;
}
}
int fun_2(void)
{
int v1 = 1, v2 = 2, v3 = 3;
fun_1(&v1, 0);
fun_1(&v2, 1);
fun_1(&v3, 2);
/* ... code ... */
return fun_1(0); // <<<< HERE >>>>
}
- is it guarantee that in the last call of 'fun_1' (return statement)
pointers to v1, v2, v3, that stored into 's' in 'fun_1', are still valid ?
- if yes, any comment is it guarantee and after optimization ??
int fun_1(int *val, int i = 0)
{
static int *s[3];
if (val && i >= 0 && i < 3) {
s = val;
return 1;
} else {
if (s[0])
do_sth(*s[0]);
return 0;
}
}
int fun_2(void)
{
int v1 = 1, v2 = 2, v3 = 3;
fun_1(&v1, 0);
fun_1(&v2, 1);
fun_1(&v3, 2);
/* ... code ... */
return fun_1(0); // <<<< HERE >>>>
}
- is it guarantee that in the last call of 'fun_1' (return statement)
pointers to v1, v2, v3, that stored into 's' in 'fun_1', are still valid ?
- if yes, any comment is it guarantee and after optimization ??