Opened 6 years ago

Last modified 2 years ago

#5294 new defect

GCC 8 compiler warnings — at Initial Version

Reported by: elexis Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch:

Description

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

In file included from ../../../source/simulation2/helpers/Pathfinding.h:26,
                 from ../../../source/simulation2/helpers/LongPathfinder.h:21,
                 from ../../../source/simulation2/helpers/LongPathfinder.cpp:20:
../../../source/simulation2/helpers/Grid.h: In instantiation of ‘T* SparseGrid<T>::GetBucket(int, int) [with T = PathfindTile]’:
../../../source/simulation2/helpers/Grid.h:238:10:   required from ‘T& SparseGrid<T>::get(int, int) [with T = PathfindTile]’
../../../source/simulation2/helpers/LongPathfinder.cpp:406:41:   required from here
../../../source/simulation2/helpers/Grid.h:194:10: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct PathfindTile’; use assignment or value-initialization instead [-Wclass-memaccess]
    memset(m_Data[b], 0, BucketSize*BucketSize*sizeof(T));
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../../source/simulation2/helpers/LongPathfinder.cpp:20:
../../../source/simulation2/helpers/LongPathfinder.h:63:8: note: ‘struct PathfindTile’ declared here
 struct PathfindTile
        ^~~~~~~~~~~~
====================================================================================================================================================================================

../../../source/ps/ModIo.cpp: In member function ‘void ModIo::StartDownloadMod(size_t)’:
../../../source/ps/ModIo.cpp:321:82: warning: ‘new’ of type ‘DownloadCallbackData’ with extended alignment 64 [-Waligned-new=]
  m_CallbackData = new DownloadCallbackData(sys_OpenFile(m_DownloadFilePath, "wb"));
                                                                                  ^
../../../source/ps/ModIo.cpp:321:82: note: uses ‘void* operator new(std::size_t)’, which does not have an alignment parameter
../../../source/ps/ModIo.cpp:321:82: note: use ‘-faligned-new’ to enable C++17 over-aligned new support

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

In file included from /usr/include/string.h:635,
                 from /usr/include/c++/8/cstring:42,
                 from /usr/include/boost/filesystem/path.hpp:36,
                 from /usr/include/boost/filesystem.hpp:16,
                 from ../../../source/lib/pch/pch_boost.h:57,
                 from ../../../source/lib/precompiled.h:76,
                 from ../../../source/pch/engine/precompiled.h:18:
In function ‘void* memcpy(void*, const void*, size_t)’,
    inlined from ‘void rewriteBuffer(u8*, u32&)’ at ../../../source/ps/Profiler2.cpp:564:10:
/usr/include/x86_64-linux-gnu/bits/string3.h:53:33: warning: ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’ forming offset [257, 4294967295] is out of the bounds [0, 256] of object ‘message’ with type ‘char [256]’ [-Warray-bounds]
   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/ps/Profiler2.cpp: In function ‘void rewriteBuffer(u8*, u32&)’:
../../../source/ps/Profiler2.cpp:563:9: note: ‘message’ declared here
    char message[CProfiler2::MAX_ATTRIBUTE_LENGTH] = {0};
         ^~~~~~~

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

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/lib/res/h_mgr.cpp: In function ‘void h_free_hd(HDATA*)’:
../../../source/lib/res/h_mgr.cpp:578:27: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct HDATA’ with no trivial copy-assignment; use assignment or value-initialization instead [-Wclass-memaccess]
  memset(hd, 0, sizeof(*hd));
                           ^
../../../source/lib/res/h_mgr.cpp:140:8: note: ‘struct HDATA’ declared here
 struct HDATA
        ^~~~~

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

../../../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) {

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

     if (start_thread(ctx, (mg_thread_func_t) worker_thread, ctx) != 0) {
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp: In function ‘std::__cxx11::wstring fromXmlChar(const xmlChar*)’:
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:96:31: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 5: ch += *source++; ch <<= 6;
                            ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:97:3: note: here
   case 4: ch += *source++; ch <<= 6;
   ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:97:31: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 4: ch += *source++; ch <<= 6;
                            ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:98:3: note: here
   case 3: ch += *source++; ch <<= 6;
   ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:98:31: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 3: ch += *source++; ch <<= 6;
                            ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:99:3: note: here
   case 2: ch += *source++; ch <<= 6;
   ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:99:31: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 2: ch += *source++; ch <<= 6;
                            ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:100:3: note: here
   case 1: ch += *source++; ch <<= 6;
   ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:100:31: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 1: ch += *source++; ch <<= 6;
                            ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:101:3: note: here
   case 0: ch += *source++;
   ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp: In constructor ‘toXmlChar::toXmlChar(const wstring&)’:
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:67:49: warning: this statement may fall through [-Wimplicit-fallthrough=]
    case 4: *--target = ((ch | 0x80) & 0xBF); ch >>= 6;
                                              ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:68:4: note: here
    case 3: *--target = ((ch | 0x80) & 0xBF); ch >>= 6;
    ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:68:49: warning: this statement may fall through [-Wimplicit-fallthrough=]
    case 3: *--target = ((ch | 0x80) & 0xBF); ch >>= 6;
                                              ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:69:4: note: here
    case 2: *--target = ((ch | 0x80) & 0xBF); ch >>= 6;
    ^~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:69:49: warning: this statement may fall through [-Wimplicit-fallthrough=]
    case 2: *--target = ((ch | 0x80) & 0xBF); ch >>= 6;
                                              ~~~^~~~~
../../../source/tools/atlas/AtlasObject/AtlasObjectXML.cpp:70:4: note: here
    case 1: *--target = (char)(ch | firstByteMark[bytesToWrite]);
    ^~~~

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

In file included from ../../../source/lib/res/graphics/tests/test_tex.cpp:17:
/path/to/0ad/source/lib/res/graphics/tests/test_tex.h: In member function ‘void TestTex::generate_encode_decode_compare(size_t, size_t, size_t, size_t, const OsPath&)’:
/path/to/0ad/source/lib/res/graphics/tests/test_tex.h:49:27: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct Tex’ with no trivial copy-assignment; use assignment or value-initialization instead [-Wclass-memaccess]
    memset(&t, 0, sizeof(t));
                           ^
In file included from /path/to/0ad/source/lib/res/graphics/tests/test_tex.h:25,
                 from ../../../source/lib/res/graphics/tests/test_tex.cpp:17:
../../../source/lib/tex/tex.h:209:8: note: ‘struct Tex’ declared here
 struct Tex
        ^~~

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

In file included from ../../../source/lib/self_test.h:38,
                 from ../../../source/pch/test/precompiled.h:24:
/path/to/0ad/source/simulation2/tests/test_Serializer.h: In member function ‘void TestSerializer::test_bounds()’:
/path/to/0ad/source/simulation2/tests/test_Serializer.h:286:59: warning: catching polymorphic type ‘class PSERROR_Serialize_OutOfBounds’ by value [-Wcatch-value=]
   TS_ASSERT_THROWS(serialize.NumberI32("x", 17, -16, 16), PSERROR_Serialize_OutOfBounds);
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/0ad/source/simulation2/tests/test_Serializer.h:287:60: warning: catching polymorphic type ‘class PSERROR_Serialize_OutOfBounds’ by value [-Wcatch-value=]
   TS_ASSERT_THROWS(serialize.NumberI32("x", -17, -16, 16), PSERROR_Serialize_OutOfBounds);
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/0ad/source/simulation2/tests/test_Serializer.h: In member function ‘void TestSerializer::test_script_exceptions()’:
/path/to/0ad/source/simulation2/tests/test_Serializer.h:769:57: warning: catching polymorphic type ‘class PSERROR_Serialize_InvalidScriptValue’ by value [-Wcatch-value=]
   TS_ASSERT_THROWS(serialize.ScriptVal("script", &obj), PSERROR_Serialize_InvalidScriptValue);

Change History (0)

Note: See TracTickets for help on using tickets.