From: Zoran V. <zv...@ar...> - 2005-06-11 09:15:41
|
Hi When you compile w/o debugging (i.e. with optimisation) the GCC spits whole-lotta stuff like that: tclthread.c:401: warning: dereferencing type-punned pointer will break strict-aliasing rules tclthread.c:401: warning: dereferencing type-punned pointer will break strict-aliasing rules The warning sems to trigger when a pointer is casted like this: enum { EAbsWaitIdx, EBroadcastIdx, ECreateIdx, EDestroyIdx, ESetIdx, ESignalIdx, ETimedWaitIdx, EWaitIdx } opt; if (!GetArgs(interp, objc, objv, opts, 'e', ECreateIdx, (int *) &opt, (void **) &condPtr)) { return TCL_ERROR; The "opt" and "condPtr" in GetArgs() are casted and it barks at them. I cannot possibly imagine changing all code to something like: enum { EAbsWaitIdx, EBroadcastIdx, ECreateIdx, EDestroyIdx, ESetIdx, ESignalIdx, ETimedWaitIdx, EWaitIdx } opt; int myOpt = (int)opt; if (!GetArgs(interp, objc, objv, opts, 'e', ECreateIdx, &myOpt, (void **) &condPtr)) { return TCL_ERROR; This would mean lots of work and may introduce errors. I've read that you can use (starting with gcc 3.3) -fno-strict-aliasing which would remove those warnings. But also, somebody said that the effect of the "-O2" is gone in such cases (haven't be able to verify) What to do? Any ideas? Zoran |