[Xorp-hackers] -Werror

Pavlin Radoslavov pavlin@icir.org
Fri, 23 Dec 2005 21:26:43 -0800


> I tried to compile CVS with gcc-4.0.2 optimise enabled and failed. 
> Bugzilla entry will follow shortly, but I think that -Werror usage should 
> be discussed though.
> 
> There have been several discussions about using it in KDE project for 
> example, but core developers always objected - many of these warnings are 
> compiler and preprocessor bugs actually and it'd be insane to fix all 
> these. In the situation where parsers and optimisers are rewritten with 
> every gcc release (okok, not with every release), it's even more insane - 
> warnings are even different with different optimise flags used.
> 
> Some examples ... Many fea classes don't compile with -Os with gcc-4.0.2, 
> but do with -O2:
> 
> fticonfig_entry_get_dummy.cc: In destructor 
> 'FtiConfigEntryGetDummy::~FtiConfigEntryGetDummy()':
> fticonfig_entry_get_dummy.cc:47: warning: control may reach end of 
> non-void function 'virtual int 
> FtiConfigEntryGetDummy::stop(std::string&)' being inlined
> 
> What it doesn't like, is:
> 
> return (XORP_OK);
> UNUSED(error_msg);
> 
> Switch places (put return after UNUSED()) and it will compile.
> 
> OSPF peer.cc doesn't compile with -Os and -O2:
> 
> peer.cc:4446: warning: statement has no effect
> peer.cc:4449: warning: statement has no effect
> peer.cc:4451: warning: statement has no effect
> peer.cc:4452: warning: statement has no effect
> 
> What it doesn't like is htonl(). Should this be removed?
> 
> Btw, linking bgp fails with (real) error with -Os, but it links with -O2. 
> I'm investigating, but should I report it at all? Or is there policy 
> which compiler flags are supported?

Thanks for the detailed investigation and for the fixes of the
compilation issues. Most of the compilation issues are fixed in CVS
(see  Bugzilla entry #435 and #448 for details).
In general, bugzilla is the best way to report such bugs (which is
exactly what you did).

About -Werror in general, we are strongly in its support, because
it is very helpful in discovering various bugs.
Indeed, occasionally we come across compiler bugs (e.g., the
ntohl()/htonl() issue inside ospf/peer.cc), but those are isolated
cases so it is still worth dealing with those cases and keep using
-Werror.

Pavlin