MantisBT - Zandronum
View Issue Details
0001393Zandronum[All Projects] Bugpublic2013-07-03 23:552018-09-30 21:34
skyrimguy 
Edward-san 
lowminoralways
closedfixed 
LinuxDebian Sidx86_64
 
1.31.3 
0001393: GCC 4.8.1 warnings while compiling Zandronum on Linux
Here are a few warnings:

/home/ggg/zandronum_build/zandronum/tools/zipdir/zipdir.c:936:8: warning: attempt to free a non-heap 
object ‘compbuf’ [-Wfree-nonheap-object]
    free(compbuf);
        ^	
/home/ggg/zandronum_build/zandronum/src/d_net.cpp:2652:33: warning: format ‘%d’ expects argument 
of type ‘int’, but argument 2 has type ‘ULONG {aka long unsigned int}’ [-Wformat=]
      players[i].userinfo.netname);
                                 ^
/home/ggg/zandronum_build/zandronum/src/team.cpp:1254:17: warning: converting to non-pointer type ‘ULONG 
{aka long unsigned int}’ from NULL [-Wconversion-null]
   return ( NULL );
                 ^
/home/ggg/zandronum_build/zandronum/upnpnat/upnpnat.cpp:481:114: warning: format ‘%d’ expects argument 
of type ‘int’, but argument 6 has type ‘std::basic_string<char>::size_type {aka long unsigned 
int}’ [-Wformat=]
  sprintf(buff,HTTP_HEADER_ACTION,pathString,host.c_str(),port,soap_message.size(),service_type.c_str(),ACTION_ADD);
                                                                                                                  
^
/home/ggg/zandronum_build/zandronum/src/d_protocol.cpp:220:43: warning: narrowing conversion of ‘(((unsigned 
int)ucmd->usercmd_t::buttons) & 127u)’ from ‘unsigned int’ to ‘BYTE {aka unsigned char}’ 
inside { } is ill-formed in C++11 [-Wnarrowing]
   BYTE bytes[4] = {  ucmd->buttons        & 0x7F,
                                           ^
/home/ggg/zandronum_build/zandronum/src/d_protocol.cpp:223:31: warning: narrowing conversion of ‘((((unsigned 
int)ucmd->usercmd_t::buttons) >> 21) & 255u)’ from ‘unsigned int’ to ‘BYTE {aka 
unsigned char}’ inside { } is ill-formed in C++11 [-Wnarrowing]
         (ucmd->buttons >> 21) & 0xFF };
                               ^
/home/ggg/zandronum_build/zandronum/src/c_console.cpp:665:36: warning: comparison between signed and 
unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < NUMNOTIFIES-1; ++j)
                                    ^
/home/ggg/zandronum_build/zandronum/src/c_console.cpp:205:42: warning: comparison between signed and 
unsigned integer expressions [-Wsign-compare]
 #define NUMNOTIFIES (NotifyStrings.Size()) // 4
                                          ^
/home/ggg/zandronum_build/zandronum/src/w_wad.cpp:794:34: warning: comparison between signed and unsigned 
integer expressions [-Wsign-compare]
   for (int i = 0; i < arc->DB.db.NumFiles; ++i)
                                  ^
/home/ggg/zandronum_build/zandronum/src/g_game.cpp:4508:36: warning: narrowing conversion of ‘BigLong(35)’ 
from ‘int’ to ‘DWORD {aka unsigned int}’ inside { } is ill-formed in C++11 [-Wnarrowing]
   DWORD time[2] = { BigLong(TICRATE), BigLong(level.time) };
                                    ^
/home/ggg/zandronum_build/zandronum/src/g_game.cpp:4508:57: warning: narrowing conversion of ‘BigLong(level.FLevelLocals::time)’ 
from ‘int’ to ‘DWORD {aka unsigned int}’ inside { } is ill-formed in C++11 [-Wnarrowing]
   DWORD time[2] = { BigLong(TICRATE), BigLong(level.time) };
                                                         ^
/home/ggg/zandronum_build/zandronum/src/gl/gl_portal.cpp:617:54: warning: narrowing conversion of ‘GLPortal::PlaneMirrorMode’ 
from ‘int’ to ‘double’ inside { } is ill-formed in C++11 [-Wnarrowing]
  double d[4]={0, PlaneMirrorMode, 0, TO_GL(origin->d)};
                                                      ^
/home/ggg/zandronum_build/zandronum/src/r_main.cpp:1233:55: warning: ‘newblend’ may be used uninitialized 
in this function [-Wmaybe-uninitialized]
    NormalLight.Maps = realcolormaps + NUMCOLORMAPS*256*newblend;
                                                       ^
/home/ggg/zandronum_build/zandronum/src/gl/gl_light.cpp:447:27: warning: comparison between signed and 
unsigned integer expressions [-Wsign-compare]
   gl_EnableFog(fogcolor!=-1);
                           ^
/home/ggg/zandronum_build/zandronum/src/gl/gl_light.cpp:450:19: warning: comparison between signed and 
unsigned integer expressions [-Wsign-compare]
    if (fogcolor!=-1)
                   ^


Total Zandronum Linux client compilation warnings: 132

Total Zandronum Linux server compilation warnings: 111
No tags attached.
zip GCC481warningsZandronumLinux.zip (50,135) 2013-07-03 23:55
/tracker/file_download.php?file_id=998&type=bug
diff warningfixes-1.3.diff (9,687) 2014-01-06 17:38
/tracker/file_download.php?file_id=1134&type=bug
diff warningfixes-2.0.diff (835) 2014-01-06 17:38
/tracker/file_download.php?file_id=1135&type=bug
txt strict-aliasing-warns.txt (14,841) 2014-01-06 17:40
/tracker/file_download.php?file_id=1136&type=bug
diff warningfixes-1.3-2.diff (4,915) 2014-04-06 20:41
/tracker/file_download.php?file_id=1192&type=bug
txt clang_warns.txt (13,356) 2014-06-15 13:44
/tracker/file_download.php?file_id=1227&type=bug
diff warningfixes-1.3-clang.diff (12,572) 2014-06-22 10:43
/tracker/file_download.php?file_id=1235&type=bug
diff warningfixes-2.0-clang.diff (12,572) 2014-06-22 10:43
/tracker/file_download.php?file_id=1236&type=bug
diff scaletext.diff (2,714) 2014-06-22 21:38
/tracker/file_download.php?file_id=1237&type=bug
Issue History
2013-07-03 23:55skyrimguyNew Issue
2013-07-03 23:55skyrimguyFile Added: GCC481warningsZandronumLinux.zip
2013-07-04 00:46skyrimguyNote Added: 0006565
2013-07-04 18:25Torr SamahoPriorityurgent => low
2013-07-04 18:25Torr SamahoSeveritymajor => minor
2014-01-03 13:41Edward-sanNote Added: 0007866
2014-01-03 13:42Edward-sanNote Edited: 0007866bug_revision_view_page.php?bugnote_id=7866#r4352
2014-01-03 13:43Edward-sanAssigned To => Edward-san
2014-01-03 13:43Edward-sanStatusnew => assigned
2014-01-03 13:47Edward-sanNote Edited: 0007866bug_revision_view_page.php?bugnote_id=7866#r4353
2014-01-06 17:38Edward-sanFile Added: warningfixes-1.3.diff
2014-01-06 17:38Edward-sanFile Added: warningfixes-2.0.diff
2014-01-06 17:40Edward-sanFile Added: strict-aliasing-warns.txt
2014-01-06 17:41Edward-sanNote Added: 0007898
2014-01-06 17:42Edward-sanNote Edited: 0007898bug_revision_view_page.php?bugnote_id=7898#r4375
2014-01-06 17:43Edward-sanNote Edited: 0007898bug_revision_view_page.php?bugnote_id=7898#r4376
2014-01-06 18:00DuskTarget Version => 2.0
2014-01-06 18:48DuskNote Added: 0007900
2014-01-10 11:01Edward-sanStatusassigned => needs review
2014-04-06 20:12Edward-sanFile Added: warningfixes-1.3-2.diff
2014-04-06 20:41Edward-sanFile Deleted: warningfixes-1.3-2.diff
2014-04-06 20:41Edward-sanFile Added: warningfixes-1.3-2.diff
2014-04-06 20:42Edward-sanNote Added: 0008508
2014-04-06 20:58Torr SamahoNote Added: 0008509
2014-04-07 20:48Torr SamahoNote Added: 0008514
2014-04-07 20:55Torr SamahoStatusneeds review => feedback
2014-06-08 00:20Edward-sanNote Added: 0008890
2014-06-08 00:20Edward-sanResolutionopen => suspended
2014-06-08 00:22Edward-sanStatusfeedback => acknowledged
2014-06-15 13:43Edward-sanNote Added: 0009371
2014-06-15 13:43Edward-sanResolutionsuspended => open
2014-06-15 13:44Edward-sanFile Added: clang_warns.txt
2014-06-15 13:45Edward-sanNote Edited: 0009371bug_revision_view_page.php?bugnote_id=9371#r4981
2014-06-15 13:46Edward-sanNote Edited: 0009371bug_revision_view_page.php?bugnote_id=9371#r4982
2014-06-15 14:13WatermelonStatusacknowledged => assigned
2014-06-22 10:43Edward-sanFile Added: warningfixes-1.3-clang.diff
2014-06-22 10:43Edward-sanFile Added: warningfixes-2.0-clang.diff
2014-06-22 10:44Edward-sanNote Added: 0009647
2014-06-22 10:44Edward-sanStatusassigned => needs review
2014-06-22 21:38Edward-sanFile Added: scaletext.diff
2014-06-22 21:40Edward-sanNote Added: 0009683
2014-06-28 19:58Edward-sanNote Edited: 0009683bug_revision_view_page.php?bugnote_id=9683#r5225
2014-06-28 19:58Edward-sanNote Edited: 0009683bug_revision_view_page.php?bugnote_id=9683#r5226
2014-06-28 19:59Edward-sanNote Edited: 0009683bug_revision_view_page.php?bugnote_id=9683#r5227
2014-06-28 19:59Edward-sanNote Edited: 0009683bug_revision_view_page.php?bugnote_id=9683#r5228
2014-10-27 10:05Edward-sanNote Added: 0010703
2014-10-27 10:05Edward-sanStatusneeds review => resolved
2014-10-27 10:05Edward-sanFixed in Version => 1.3
2014-10-27 10:05Edward-sanResolutionopen => fixed
2014-10-27 10:06Edward-sanTarget Version2.0 => 1.3
2018-09-30 21:34Blzut3Statusresolved => closed

Notes
(0006565)
skyrimguy   
2013-07-04 00:46   
I forgot to mention, this is while compiling Zandronum 1.1-alpha-r130630-2011 and compilation is successful.
(0007866)
Edward-san   
2014-01-03 13:41   
(edited on: 2014-01-03 13:47)
Working on this, with reference to zandronum 1.3 beta and zandronum 2.0 beta. Keep in mind that the warnings which are from gzdoom are ignored, hence also the ones which are from sources different from src/ and upnpnat/ are ignored.

(0007898)
Edward-san   
2014-01-06 17:41   
(edited on: 2014-01-06 17:43)
Some of the warnings are fixed and the fixes are attached as patches for 1.3 and 2.0 (2.0 contains only the fixes which are not present in 1.3, the 1.3 patch can be merged in 2.0).

The other warnings are the following kind:

1)some are inherited from gzdoom and can't be fixed without messing the codebase update schedule;
2)some are false positives, like the -Wmaybe-uninitialized warnings
3)some others can be fixed, like the -Wunused-result warnings, but I leave to Torr's opinion, because these ones are not fixed in zdoom
4)the -Wstrict-aliasing warnings, attached as the txt file here, are the hard part which I have no idea: for example, in src/p_mobj.cpp, line 348:


arc << ... << (DWORD &)lNetID // [BC] We need to archive this so that it's restored properly when going between maps in a hub.


gcc reports:

warning: dereferencing type-punned pointer will break strict-aliasing rules


is it false positive? if not, is it there another way to achieve what Carn wanted without breaking strict aliasing rule?

One peculiar thing I noticed is that zdoom codebase has no such strict-aliasing violation...

(0007900)
Dusk   
2014-01-06 18:48   
Quote

[19:51:53] <Dusk> edward-san, i think FArchive needs an operator<< overload for ULONG
[19:52:05] <Dusk> then you can get rid of the type punning
[19:52:32] <Dusk> (if it were up to me though i'd just make these variables just be int)
[20:00:17] <edward-san> interestingly, there's SWAP_* which is used in operator<<
[20:00:43] <edward-san> since ULONG can be unsigned int (in wine... :\)
[20:00:48] <edward-san> ...
[20:34:16] <Dusk> who plays zandronum with wine today :P
[20:34:35] <Dusk> i think it's a mere relic from the days when skulltag was closed source
[20:34:38] <Dusk> we should probably drop it
(0008508)
Edward-san   
2014-04-06 20:42   
Final changes available.
(0008509)
Torr Samaho   
2014-04-06 20:58   
I added the new 1.3 patch.
(0008514)
Torr Samaho   
2014-04-07 20:48   
I also added your 2.0 patch.
(0008890)
Edward-san   
2014-06-08 00:20   
Ok, now the only problem is the FArchive type punning thing. I'll suspend this for now.
(0009371)
Edward-san   
2014-06-15 13:43   
(edited on: 2014-06-15 13:46)
Let me add clang warnings to the wheel (I changed my local copy to allow clang to compile)!

Posting them asap.

[edit] Done, removed the (g)zdoom codebase warnings while at it.

(0009647)
Edward-san   
2014-06-22 10:44   
Uploaded the fixes to clang warnings for 1.3 and 2.0.
(0009683)
Edward-san   
2014-06-22 21:40   
(edited on: 2014-06-28 19:59)
I made a patch which sets con_scaletext back to Int (was set to Bool in the old source), as it caused a warning in gcc I noticed just now. Do you know something about the reason for that, Torr?

Also, I'd like to discuss about the other portions of patches which were not merged in the 'stable' repository.

(0010703)
Edward-san   
2014-10-27 10:05   
I'll continue the GCC/Clang warnings history in a new ticket. This has done enough for the time being.