Opened 6 years ago

Last modified 2 years ago

#5294 new defect

GCC 8 compiler warnings

Reported by: elexis Owned by: Alex
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch: Phab:D2055, Phab:D2099, Phab:D2102, Phab:D2153

Description (last modified by Stan)

When I compile 0ad with gcc 8.1.0, I get the following warnings:

====================================================================================================================================================================================

In file included from ../../../source/pch/atlas/precompiled.h:24:
../../../source/tools/atlas/GameInterface/Messages.h: In function ‘void AtlasMessage::fGetTerrainGroupPreviews(AtlasMessage::qGetTerrainGroupPreviews*)’:
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 struct sTerrainTexturePreview
        ^~~~~~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 struct sTerrainTexturePreview
        ^~~~~~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../../../source/tools/atlas/GameInterface/Messages.h:292:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]

====================================================================================================================================================================================

../../../source/third_party/mongoose/mongoose.cpp: In function ‘mg_context* mg_start(mg_callback_t, void*, const char**)’:
../../../source/third_party/mongoose/mongoose.cpp:4297:40: warning: cast between incompatible function types from ‘void (*)(mg_context*)’ to ‘mg_thread_func_t’ {aka ‘void* (*)(void*)’} [-Wcast-function-type]
   start_thread(ctx, (mg_thread_func_t) master_thread, ctx);
                                        ^~~~~~~~~~~~~
../../../source/third_party/mongoose/mongoose.cpp:4301:46: warning: cast between incompatible function types from ‘void (*)(mg_context*)’ to ‘mg_thread_func_t’ {aka ‘void* (*)(void*)’} [-Wcast-function-type]
     if (start_thread(ctx, (mg_thread_func_t) worker_thread, ctx) != 0) {

====================================================================================================================================================================================

Attachments (1)

build-log.txt (686.3 KB ) - added by elexis 5 years ago.
More than tenthousand compiler warnings with GCC 9

Download all attachments as: .zip

Change History (27)

comment:1 by elexis, 5 years ago

Keywords: simple added
Milestone: BacklogAlpha 24

Phab:D1395, Phab:D1432 for the Atlas one.

comment:2 by Alex, 5 years ago

Owner: set to Alex

comment:3 by elexis, 5 years ago

Description: modified (diff)

by elexis, 5 years ago

Attachment: build-log.txt added

More than tenthousand compiler warnings with GCC 9

comment:4 by elexis, 5 years ago

Keywords: simple removed
Patch: Phab:D2055

comment:5 by elexis, 5 years ago

In 22443:

Fix some gcc 8 and gcc 9 compiler warnings that were thrown 4500 times.

Refs #5294
Differential Revision: https://code.wildfiregames.com/D2055
Reviewed By: Vladislav

comment:6 by elexis, 5 years ago

Patch: Phab:D2055Phab:D2055,Phab:D2099

comment:7 by elexis, 5 years ago

In 22511:

Fix the -Wclass-memaccess compiler warning in the pathfinders Grid.h, refs #5294.

Differential Revision: https://code.wildfiregames.com/D2099
Reviewed By: historic_bruno, wraitii

comment:8 by elexis, 5 years ago

Patch: Phab:D2055,Phab:D2099Phab:D2055,Phab:D2099,Phab:D2102

comment:9 by elexis, 5 years ago

Patch: Phab:D2055,Phab:D2099,Phab:D2102Phab:D2055, Phab:D2099, Phab:D2102

comment:10 by elexis, 5 years ago

clang warnings as of r22601:

Atlas one comes from r22335 which has a proposed solution in Phab:rP22335. glooxwrapper one comes from r19703 and has a proposed solution in Phab:D2094.

In file included from ../../../source/lobby/glooxwrapper/glooxwrapper.cpp:20:
../../../source/lobby/glooxwrapper/glooxwrapper.h:642:10: warning: private field 'm_Owned' is not used [-Wunused-private-field]
                                bool m_Owned;
                                     ^
---------------------------------------------------------------------------------------------------

In file included from ../../../source/ps/XML/XeroXMB.cpp:20:
In file included from ../../../source/ps/XML/Xeromyces.h:32:
../../../source/ps/XML/XeroXMB.h:221:15: warning: private field 'm_Pointer' is not used [-Wunused-private-field]
                const char* m_Pointer;
                            ^
../../../source/ps/XML/XeroXMB.h:290:15: warning: private field 'm_Pointer' is not used [-Wunused-private-field]
                const char* m_Pointer;
                            ^
---------------------------------------------------------------------------------------------------

../../../source/lib/res/h_mgr.cpp:99:18: warning: unused variable 'TAG_MASK' [-Wunused-const-variable]
static const u64 TAG_MASK = 0xFFFFFFFF; // safer than (1 << 32) - 1
                 ^
../../../source/lib/res/h_mgr.cpp:114:19: warning: unused function 'h_tag' [-Wunused-function]
static inline Tag h_tag(Handle h)
                  ^
---------------------------------------------------------------------------------------------------
../../../source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp:175:50: warning: result of comparison against a string literal is unspecified
      (use strncmp instead) [-Wstring-compare]
                if (in["Object"]["Properties"]["@autoflatten"] == "1")
                                                               ^  ~~~
../../../source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp:178:50: warning: result of comparison against a string literal is unspecified
      (use strncmp instead) [-Wstring-compare]
                if (in["Object"]["Properties"]["@castshadows"] == "1")
                                                               ^  ~~~

comment:11 by elexis, 5 years ago

In 22619:

Fix ModIo.cpp gcc 7 compiler warning about extended alignment by using a pointer for hash_state as expected by sodium anyhow, following rP21759, refs #5294.

Differential Revision: https://code.wildfiregames.com/D2102
Reviewed By: Itms
Comments By: historic_bruno

comment:12 by elexis, 5 years ago

Patch: Phab:D2055, Phab:D2099, Phab:D2102Phab:D2055, Phab:D2099, Phab:D2102,Phab:D2153

comment:13 by elexis, 5 years ago

In 22621:

Remove unused texture test helper function obsolete since rP8094 and rP14836 that throws a compiler warning with gcc 7 and beyond.

Refs #2456, #5294.
Differential Revision: https://code.wildfiregames.com/D2153

comment:14 by elexis, 5 years ago

In 22624:

Fix Profiler2 gcc 8 compiler warning about possible out-of-bounds array access and replace auto with their type, refs #5294, rP18423.

Tested with gcc 9, clang 8

comment:15 by elexis, 5 years ago

In 22626:

Fix gcc 8 compiler warning in FileIo.cpp about truncating use of strncpy [-Wstringop-truncation].

Refs #5294
Differential Revision: https://code.wildfiregames.com/D2159
Tested on: gcc 9, Jenkins

comment:16 by elexis, 5 years ago

In 22678:

Fix unreported glooxwrapper leaks following rP19703, refs #2305.

Fixes an occurring leak indicated by the reported clang unused variable compiler warning, refs #5294, #5550,
by adding the missing glooxwrapper::Jingle::Session::Session destructor .

Fix two leaks that would have occurred if the according code had been used:
Delete unused glooxwrapper::Jingle::ICEUDP::ICEUDP instead of adding the missing destructor.
Delete unused glooxwrapper::Jingle::Content::Content instead of adding the missing destructor.

Explain why glooxwrapper::Client::registerStanzaExtension doesn't leak the new StanzaExtensionWrapper.
Explain why glooxwrapper::Jingle::Session::sessionInitiate doesn't leak the new gloox::Jingle::Content, nor the new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::registerPlugins doesn't leak the new gloox::Jingle::Content and new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::createSession doesn't leak the gloox::Jingle::Session.

I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.

Use references in the StunClient and glooxwrapper to anticipate any confusion as to whose obligation it is to delete variables when they are passed around across several files.
Use static_cast and reinterpret_cast instead of C-style casts in the StunClient.

Differential Revision: https://code.wildfiregames.com/D2094
Refs D2093 for the reported leaks.
Reviewed By: Josh
Comments By: fcxSanya, Vladislav for D2094, and echotangoecho, leper in rP19703

comment:17 by elexis, 5 years ago

In 22764:

Fix unused glooxwrapper variable following rP19703, refs #2305, #5294, #5550.

The class didn't leak the m_Wrapped gloox Jingle for this program since it's not set to owned, and it's not set to owned because gloox deletes it.
It would have leaked if some other app would have used glooxwrapper with owned = true, if gloox has a situation for that.

Differential Revision: https://code.wildfiregames.com/D2090

comment:18 by Stan, 4 years ago

Patch: Phab:D2055, Phab:D2099, Phab:D2102,Phab:D2153Phab:D2055, Phab:D2099, Phab:D2102, Phab:D2153

Add a space so we can click on differentials

comment:19 by Stan, 3 years ago

Description: modified (diff)

Most of the warnings were fixed, only those remain now

comment:20 by Freagarach, 3 years ago

I also get:

test_MapGenerator.cpp
In file included from ../../../source/lib/os_path.h:26,
                 from ../../../source/lib/self_test.h:28,
                 from ../../../source/simulation2/system/ComponentTest.h:21,
                 from ../../../source/pch/test/precompiled.h:22:
../../../source/lib/path.h: In member function ‘virtual void TestMapGenerator::setUp()’:
../../../source/lib/path.h:265:68: warning: ‘<anonymous>.Path::separator’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   debug_printf("Path %s, separator %c\n", string8().c_str(), (char)separator);
===============================================================
test_scripts.cpp
In file included from ../../../source/lib/os_path.h:26,
                 from ../../../source/lib/self_test.h:28,
                 from ../../../source/simulation2/system/ComponentTest.h:21,
                 from ../../../source/pch/test/precompiled.h:22:
../../../source/lib/path.h: In member function ‘virtual void TestComponentScripts::setUp()’:
../../../source/lib/path.h:265:68: warning: ‘<anonymous>.Path::separator’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   debug_printf("Path %s, separator %c\n", string8().c_str(), (char)separator);
                                                                    ^~~~~~~~~
====================================================
In file included from ../../../source/lib/os_path.h:26,
                 from ../../../source/lib/self_test.h:28,
                 from ../../../source/simulation2/system/ComponentTest.h:21,
                 from ../../../source/pch/test/precompiled.h:22:
../../../source/lib/path.h: In function ‘OsPath DataDir()’:
../../../source/lib/path.h:265:68: warning: ‘<anonymous>.Path::separator’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   debug_printf("Path %s, separator %c\n", string8().c_str(), (char)separator);
                                                                    ^~~~~~~~~

with GCC 8.4.

comment:21 by Stan, 3 years ago

In 24487:

Fix most Clang 10 Warnings

Refs: #5550, #5294

Remove dead code from Phab:rP16704
Fix buggy code from Phab:rP15909
Comments by: @wraitii, @vladislavbelov

Differential Revision: https://code.wildfiregames.com/D3177

comment:22 by Stan, 3 years ago

Milestone: Alpha 24Alpha 25

Unlikely to get fixed for A24

comment:23 by wraitii, 3 years ago

Milestone: Alpha 25Alpha 26

comment:24 by Stan, 2 years ago

Description: modified (diff)

HDATA warning was fixed in

In r26369:

Removes unused and redundant h_mgr after r25936 and r26368.

comment:25 by Stan, 2 years ago

In 26370:

Fixes two clang warnings.
Refs #5550 #5294

comment:26 by Freagarach, 2 years ago

Milestone: Alpha 26Backlog
Note: See TracTickets for help on using tickets.