typedef struct
{
int a;
int b;
} my_struct_t;
void f2(const my_struct_t *my_struct, int *b)
{
*b = my_struct->a + 1;
}
void f1(my_struct_t *my_struct)
{
f2(my_struct, &(my_struct->b));
}
The my_struct
parameter in f2()
is declared as const
so none of its members can be modified, but the b
parameter is a pointer to a member of my_struct
which is modified.
I wonder if, according to the c99
standard, the way I called f2()
is legal or could lead to undefined behavior?
You need to sign in to view this answers
Leave feedback about this