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 |
From: Vlad S. <vl...@cr...> - 2005-06-11 19:50:26
|
I went through google about this and found out that many projects like Linux, PostgreSQL and others use -fno-strict-aliasing. And nobody could determine if this affects optimnization, so we can use that flag as well and in the meantime slowly change the code. Zoran Vasiljevic wrote: > 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 > > > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you > shotput > a projector? How fast can you ride your desk chair down the office luge > track? > If you want to score the big prize, get to know the little guy. Play to > win an NEC 61" plasma display: http://www.necitguy.com/?r=20 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Zoran V. <zv...@ar...> - 2005-06-11 20:03:48
|
Am 11.06.2005 um 21:50 schrieb Vlad Seryakov: > I went through google about this and found out that many projects > like Linux, PostgreSQL and others use -fno-strict-aliasing. And > nobody could determine if this affects optimnization, so we can use > that flag as well and in the meantime slowly change the code. > This is what I thought at the first glance but did not want to undertake anything until we clear this out. I have zero experience about what it meany to use -O switch because we always compile with symbols and w/o optimization. This is far more important (to get a decent coredump) then some (possible marginal) speed improvment. Our server itself is network/IO-bound and not CPU bound, hence we do not really care. But you might, therefore I thougt it is better to ask. Cheers Zoran |
From: Vlad S. <vl...@cr...> - 2005-06-11 20:12:57
|
I will need as much as possible speed for my next project where i will use NS but i do not experience with gcc optimization either. But in previous work i always wanted debugging info and sometimes -ON flags messed with gdb because of optimization. I say let's use -fno-strict-aliasing but use -fstrict-aliasing when compile for make test. That way we can clean up code. Zoran Vasiljevic wrote: > > Am 11.06.2005 um 21:50 schrieb Vlad Seryakov: > >> I went through google about this and found out that many projects >> like Linux, PostgreSQL and others use -fno-strict-aliasing. And >> nobody could determine if this affects optimnization, so we can use >> that flag as well and in the meantime slowly change the code. >> > > This is what I thought at the first glance but did not want > to undertake anything until we clear this out. > I have zero experience about what it meany to use -O switch > because we always compile with symbols and w/o optimization. > This is far more important (to get a decent coredump) then > some (possible marginal) speed improvment. Our server itself > is network/IO-bound and not CPU bound, hence we do not really > care. But you might, therefore I thougt it is better to ask. > > Cheers > Zoran > > > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you > shotput > a projector? How fast can you ride your desk chair down the office luge > track? > If you want to score the big prize, get to know the little guy. Play to > win an NEC 61" plasma display: http://www.necitguy.com/?r=20 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2005-06-12 05:06:58
|
On 6/11/05, Zoran Vasiljevic <zv...@ar...> wrote: > Hi >=20 > When you compile w/o debugging (i.e. with optimisation) > the GCC spits whole-lotta stuff like that: >=20 > 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 >=20 > The warning sems to trigger when a pointer is casted like this: >=20 > enum { > EAbsWaitIdx, EBroadcastIdx, ECreateIdx, EDestroyIdx, ESetIdx, > ESignalIdx, ETimedWaitIdx, EWaitIdx > } opt; >=20 > if (!GetArgs(interp, objc, objv, opts, 'e', ECreateIdx, > (int *) &opt, (void **) &condPtr)) { > return TCL_ERROR; >=20 > The "opt" and "condPtr" in GetArgs() are casted and it barks > at them. I cannot possibly imagine changing all code to > something like: >=20 > enum { > EAbsWaitIdx, EBroadcastIdx, ECreateIdx, EDestroyIdx, ESetIdx, > ESignalIdx, ETimedWaitIdx, EWaitIdx > } opt; > int myOpt =3D (int)opt; >=20 > if (!GetArgs(interp, objc, objv, opts, 'e', ECreateIdx, > &myOpt, (void **) &condPtr)) { > return TCL_ERROR; >=20 > This would mean lots of work and may introduce errors. >=20 > 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) >=20 > What to do? > Any ideas? For much of the command parsing, I think something like this is fine: int opt; static CONST char *opts[] =3D { "cleanup", "list", "create", "put", "get", NULL }; enum { CCleanupIdx, CListIdx, CCreateIdx, CPutIdx, CGetIdx }; if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0, &opt) !=3D TCL_OK) { return TCL_ERROR; } |
From: Zoran V. <zv...@ar...> - 2005-06-12 09:51:17
|
Am 12.06.2005 um 07:06 schrieb Stephen Deasey: > > > For much of the command parsing, I think something like this is fine: > > int opt; > > static CONST char *opts[] = { > "cleanup", "list", "create", "put", "get", NULL > }; > enum { > CCleanupIdx, CListIdx, CCreateIdx, CPutIdx, CGetIdx > }; > > if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0, &opt) > != TCL_OK) { > return TCL_ERROR; > } > > Yes. Indeed. We should gradually go and fix those. I will do that while walking thru. You can do as well if at the right place. Zoran |
From: Zoran V. <zv...@ar...> - 2005-06-13 09:10:06
|
Am 12.06.2005 um 11:51 schrieb Zoran Vasiljevic: > > Yes. Indeed. We should gradually go and fix those. > I will do that while walking thru. You can do as well > if at the right place. Gradually or not gradually, I had some spare time yesterday afternoon and have fixed all of those. We can consider this one solved. Cheers Zoran |