Compilation warnings with GCC5
Bug #1455763 reported by
Hans Joachim Desserud
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
After some initial trouble (bug 1432339) I've successfully built Widelands with GCC5, more specifically 5.1.1-5.
I've attached a list of the warnings I got while compiling. I know we were warning-free with GCC at one point and it would be nice to get there again. It makes it much easier to spot when new warnings are introduced and fix potentially dodgy behaviour in the code.
I looked at some of them, particularly the argument type ones, but didn't really get anywhere.
Related branches
lp:~widelands-dev/widelands/compiler_warnings_20170619
- Klaus Halfmann: Needs Resubmitting
- GunChleoc: Pending requested
-
Diff: 813 lines (+146/-53)34 files modifiedCMakeLists.txt (+6/-0)
src/base/macros.h (+15/-0)
src/base/wexception.h (+5/-5)
src/economy/economy.cc (+2/-0)
src/economy/test/CMakeLists.txt (+1/-0)
src/economy/test/test_road.cc (+3/-0)
src/economy/test/test_routing.cc (+4/-0)
src/economy/ware_instance.cc (+2/-0)
src/editor/ui_menus/main_menu_random_map.cc (+0/-2)
src/graphic/animation.cc (+1/-1)
src/graphic/text/bidi.cc (+4/-0)
src/io/filesystem/filesystem_exceptions.h (+10/-6)
src/io/filesystem/test/CMakeLists.txt (+1/-0)
src/io/filesystem/test/test_filesystem.cc (+4/-0)
src/io/streamread.h (+2/-1)
src/logic/map_objects/bob.cc (+8/-1)
src/logic/map_objects/immovable.cc (+4/-0)
src/logic/map_objects/tribes/building.cc (+4/-0)
src/logic/map_objects/tribes/soldier.cc (+1/-2)
src/logic/map_objects/tribes/worker.cc (+10/-0)
src/network/gamehost.cc (+1/-2)
src/network/netclient.cc (+5/-0)
src/network/nethost.cc (+6/-0)
src/notifications/test/CMakeLists.txt (+1/-0)
src/notifications/test/notifications_test.cc (+4/-0)
src/scripting/lua_errors.cc (+1/-0)
src/scripting/lua_game.cc (+0/-2)
src/scripting/lua_map.cc (+6/-6)
src/scripting/test/CMakeLists.txt (+1/-0)
src/scripting/test/test_luna.cc (+29/-19)
src/ui_basic/progressbar.cc (+1/-1)
src/ui_fsmenu/launch_spg.h (+1/-1)
src/wui/game_message_menu.cc (+3/-2)
src/wui/shipwindow.cc (+0/-2)
tags: |
added: cleanups removed: gcc |
To post a comment you must log in.
This one is from third party code and has been there since we started using Eris:
../../third_ party/libthird_ party_eris. a(loslib. c.o): In function `os_tmpname': widelands/ src/third_ party/eris/ loslib. c:108: warning: the use of `tmpnam' is dangerous, better use `mkstemp' widelands/ src/scripting/ eris.h: 25:0,
from /home/debian/ widelands/ src/scripting/ persistence. cc:27: widelands/ src/third_ party/eris/ eris.h: 145:38: warning: redundant redeclaration of ‘int luaopen_ eris(lua_ State*) ’ in same scope [-Wredundant-decls] eris(lua_ State* L);
^
/home/debian/
In file included from /home/debian/
/home/debian/
LUA_API int luaopen_
The molog messages like the one below won't fix - the compiler can't handle the polymorphic pointer type used by %p in sprintf. Both Tibor and me tried to fix these and did the research.
/home/debian/ widelands/ src/logic/ bob.cc: In member function ‘virtual void Widelands: :Bob::log_ general_ info(const Widelands: :EditorGameBase &)’: widelands/ src/logic/ bob.cc: 1002:30: warning: format ‘%p’ expects argument of type ‘void*’, but argument 3 has type ‘Widelands: :Player* ’ [-Wformat=]
^
/home/debian/
molog("Owner: %p\n", m_owner);
This leaves us with the following warnings to try and fix:
/home/debian/ widelands/ src/map_ io/map_ players_ messages_ packet. cc: In member function ‘void Widelands: :MapPlayersMess agesPacket: :read(FileSyste m&, Widelands: :EditorGameBase &, bool, Widelands: :MapObjectLoade r&)’: widelands/ src/map_ io/map_ players_ messages_ packet. cc:80:41: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘Widelands: :Message: :Type’ [-Wformat=]
begin- >second- >body ().c_str());
^ widelands/ src/map_ io/map_ players_ messages_ packet. cc:80:41: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 8 has type ‘Widelands: :Message: :Status’ [-Wformat=] widelands/ src/map_ io/map_ players_ view_packet. cc: In member function ‘void Widelands: :MapPlayersView Packet: :write( FileSystem& , Widelands: :EditorGameBase &, Widelands: :MapObjectSaver &)’: widelands/ src/map_ io/map_ players_ view_packet. cc:1145: 12: warning: suggest parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’ [-Wparentheses] widelands/ src/map_ io/map_ players_ view_packet. cc:1147: 12: warning: suggest parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’ [-Wparentheses] widelands/ src/map_ io/map_ players_ view_packet. cc:1149: 12: warning: suggest parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’ [-Wparentheses]
/home/debian/
/home/debian/
/home/debian/
/home/debian/
if (!bl_seen & (f_everseen | bl_everseen))
^
/home/debian/
if (!br_seen & (f_everseen | br_everseen))
^
/home/debian/
if (!r_seen & (f_everseen | r_everseen))
In file included from /home/debian/ widelands/ src/logic/ instances. cc:20:0: widelands/ src/logic/ instances. h: In constructor ‘Widelands: :MapObject: :MapObject( const Widelands: :MapObjectDescr *)’: widelands/ src/logic/ instances. h:366:27: warning: ‘Widelands: :MapObject: :m_logsink’ will be initiali...
/home/debian/
/home/debian/