"const" means that the contants of the object can not be modified (through that name; it may be aliased). In this case, the variable _tmp, which is not const, is assigned from *_from, which is const. But that's no problem, since this operation just modifies _tmp, not *_from. So it feels like the compiler is in error. But I haven't checked the standard...
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-03-11 20:33: Subject: const
t[iny]cc says,
/home/mirar/pike/src/modules/HTTPLoop/accept_and_parse.c:550: cannot cast 'const struct svalue' to 'struct svalue'
I assume this is because,
550: assign_svalue_no_free(sp++, &arg->args);
#define assign_svalue_no_free_unlocked(X,Y) do {\ struct svalue _tmp;\
struct svalue *_to=(X);\ const struct svalue *_from=(Y);\
check_type(_from->type); check_refs(_from);\
*_to=_tmp=*_from;\
if(_tmp.type <= MAX_REF_TYPE) add_ref(_tmp.u.dummy);\ }while(0)
it works if I remove the "const". But is it the correct solution? const in C confuses me.
/ Mirar