[CLN-list] Re: optimization and warnings [Was: CLN 1.2.0]

Richard B. Kreckel kreckel at ginac.de
Tue Jan 22 00:42:01 CET 2008


Bruno Haible wrote:
> Alexei Sheplyakov wrote:
>> I'm not sure if CLN code is safe to compile with plain -O2.
>>
>> 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
>>
>> Just for the record, I use
>> g++-4.1 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).
> 
> Attached is a proposed patch that removes most of the warnings. They cause
> two additional instructions to be added to the functions cl_float_to_FF_pointer
> and cl_double_to_DF_pointer, but this is worth the gain of being able to
> compile cln with -O2 with modern gcc. Richy, ok to apply?

Is this a technical question about CVS management? If so, sure, check it 
in on the main branch, please! Thanks.

> Jörg Arndt wrote:
>>  (2) no warnings!, I suggest to use
>>  -W -Wall -Wconversion -Wsign-promo -Wsign-compare -Wunused \
>>  -Wshadow -Wundef
> 
> While I agree that -Wall is generally useful, and -W is sometimes useful,
> the others spew too many warnings on perfectly valid code, IMO. Your mileage
> might vary, of course.

I fully agree. Cruel flamewars have been fought about eradicating or not 
  compiler warnings in application code. This one still makes me shiver:
<http://www.ginac.de/pipermail/ginac-devel/2002-September/thread.html#475>.

Well, we don't have problems with -Wundef and -Wunused.

(Except that older versions of GCC appear not to know about Alexei's 
newly introduced flatten attribute: 
float/dfloat/division/cl_DF_fceil.cc:21: warning: `flatten' attribute 
directive ignored.)

   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the CLN-list mailing list