[CLN-list] Re: optimization and warnings [Was: CLN 1.2.0]
Joerg Arndt
arndt at jjj.de
Mon Jan 21 03:09:26 CET 2008
Hi,
* Alexei Sheplyakov <varg at theor.jinr.ru> [Jan 21. 2008 12:33]:
> Hello!
>
> On Sun, Jan 20, 2008 at 12:17:51PM +1100, Joerg Arndt wrote:
>
> > by default you use
> > (1) only -O, I suggest to use -O2 (but not -O3).
>
> I'm not sure if CLN code is safe to compile with plain -O2.
This would be a serios problem IMHO!
>
> With CXXFLAGS="-m64 -O2 -Wall -march=k8 -finline-limit=2000" I get tons of
> warnings like
>
> ../../include/cln/number.h: In constructor 'cln::cl_number::cl_number(float)':
> ../../include/cln/number.h:238: warning: type-punning to incomplete type might break strict-aliasing rules
> ../../include/cln/number.h: In member function 'cln::cl_number& cln::cl_number::operator=(float)':
> ../../include/cln/number.h:238: warning: type-punning to incomplete type might break strict-aliasing rules
> ../../include/cln/number.h: In constructor 'cln::cl_number::cl_number(double)':
> ../../include/cln/number.h:239: warning: type-punning to incomplete type might break strict-aliasing rules
Then -no-strict-aliasing should be used!
It seems to me that with strict aliasing and ignoring the warnings
we just proceed "fingers crossed" (?)
>
> Just for the record, I use
> g++-4.1 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).
>
> > (2) no warnings!, I suggest to use
> > -W -Wall -Wconversion -Wsign-promo -Wsign-compare -Wunused \
> > -Wshadow -Wundef
>
> -Wall spews a lot of warnings, and signal/noise ratio is quite low for
> this to be useful.
I do that for my stuff all the time:
I consider an warning as a problem and fix it.
When I _know_ there is no problem then I use
a (C-style) cast and comment it.
I found quite a few subtle problems by doing this.
>
> > ... and -Werror if you are daring
>
> Unfortunately, CLN won't compile with -Werror.
Clearly so.
I use -Werror and do a make -k ("keep going"),
then I go through the file where the problems occur.
>
> Best regards,
> Alexei
>
after all the above is done (a monumental task
with CLN, obviously) valgrind pointed me to a
few _very_ subtle problems which I'd never found
by other other means!
cheers, jj
More information about the CLN-list
mailing list