Jump to content

Warnings when compiling


fatherbushido
 Share

Recommended Posts

I have many messages when compiling since few revs:

Spoiler

 

ElevationHandlers.cpp
../../../source/gui/CInput.cpp: In member function ‘virtual InReaction CInput::ManuallyHandleEvent(const SDL_Event_*)’:
../../../source/gui/CInput.cpp:486:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
    cooked = '\n'; // Change to '\n' and do default:
                 ^
../../../source/gui/CInput.cpp:489:3: note: here
   default: // Insert a character
   ^~~~~~~
Patch.cpp
CStrIntern.cpp
CommandHandlers.cpp
In member function ‘void CInput::UpdateText(int, int, int)’:
cc1plus: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’: specified size 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
ObjectManager.cpp
MapHandlers.cpp
CCmpFootprint.cpp
Filesystem.cpp
GUIManager.cpp
CCmpCommandQueue.cpp
Globals.cpp
GameView.cpp
SavedGame.cpp
ICmpUnitRenderer.cpp
TerrainHandlers.cpp
ICmpObstructionManager.cpp
ShaderDefines.cpp
CCmpOwnership.cpp
CProgressBar.cpp
ICmpVisibility.cpp
CGUI.cpp
In file included from ../../../source/pch/atlas/precompiled.h:24:0:
../../../source/tools/atlas/GameInterface/Messages.h: In function ‘void AtlasMessage::fGetTerrainGroupPreviews(AtlasMessage::qGetTerrainGroupPreviews*)’:
../../../source/tools/atlas/GameInterface/Messages.h:285: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:285: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:285: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:285: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:285: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:285:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Pyrogenesis.cpp

[...]

AtlasObjectXML.cpp
SkyManager.cpp
../../../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]);
    ^~~~
ICmpMotion.cpp
AtlasObjectJS.cpp
format.cpp
ICmpMirage.cpp
ICmpMinimap.cpp
precompiled.cpp
PostprocManager.cpp
Preprocessor.cpp
TerrainRenderer.cpp
../../../source/ps/Preprocessor.cpp: In member function ‘CPreprocessor::Token CPreprocessor::GetArgument(CPreprocessor::Token&, bool)’:
../../../source/ps/Preprocessor.cpp:773:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 Error (Line, "Unfinished list of arguments");
                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/ps/Preprocessor.cpp:774:13: note: here
             case Token::TK_ERROR:
             ^~~~
../../../source/ps/Preprocessor.cpp: In member function ‘CPreprocessor::Token CPreprocessor::GetArguments(int&, CPreprocessor::Token*&, bool)’:
../../../source/ps/Preprocessor.cpp:846:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 Error (Line, "Unfinished list of arguments");
                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/ps/Preprocessor.cpp:847:13: note: here
             case Token::TK_ERROR:
             ^~~~
../../../source/ps/Preprocessor.cpp: In member function ‘CPreprocessor::Token CPreprocessor::Parse(const CPreprocessor::Token&)’:
../../../source/ps/Preprocessor.cpp:1276:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 if (empty_lines)
                 ^~
../../../source/ps/Preprocessor.cpp:1285:13: note: here
             case Token::TK_WHITESPACE:
             ^~~~
ICmpVisual.cpp

 

 

Link to comment
Share on other sites

It looks like you have enabled -Wimplicit-fallthrough in GCC/Clang. And to prevent this, you need to add a comment like or disable the option:

case 0:
...
// fall through
case 1:

https://stackoverflow.com/questions/45129741/gcc-7-wimplicit-fallthrough-warnings-and-portable-way-to-clear-them

https://dzone.com/articles/implicit-fallthrough-in-gcc-7

Edited by vladislavbelov
Link to comment
Share on other sites

Thx for the ref.

@vladislavbelov: some warnings seem not related to that, do they?

edit: those ones remain

Spoiler

In file included from ../../../source/pch/atlas/precompiled.h:24:0:
../../../source/tools/atlas/GameInterface/Messages.h: In function ‘void AtlasMessage::fGetTerrainGroupPreviews(AtlasMessage::qGetTerrainGroupPreviews*)’:
../../../source/tools/atlas/GameInterface/Messages.h:285: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:285: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:285: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:285: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:285: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:285:8: warning: ‘#‘target_mem_ref’ not supported by dump_expr#<expression error>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
CinemaHandler.cpp


and

Spoiler

Renderer.cpp
In member function ‘void CInput::UpdateText(int, int, int)’:
cc1plus: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’: specified size 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
JSInterface_VFS.cpp

 

Link to comment
Share on other sites

1 hour ago, fatherbushido said:

cc1plus: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’: specified size 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]

We don't use memset/__builtin_memset directly inside CInput at all. So it looks like a compiler issue (wrong message or something else):

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79095

1 hour ago, fatherbushido said:

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

It looks like the compile can't follow some call stack. We use threads/events in Atlas (to send between wxWidgets/Pyrogenesis), so the compiler can't find a place where the var was really initialized. By the code there is only the one place where it has assigned AFAIK.

Edited by vladislavbelov
Link to comment
Share on other sites

  • 7 months later...

Resurrecting an old thread...

I just built 0AD for the first time and saw a bunch of these compiler warnings:

../../../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;
                            ~~~^~~~~

To get my feet wet with 0AD, I think I can rewrite the code to avoid these warnings and be a little cleaner.

  1. These break-less case statements are all repetitive. I could replace them with for loops.
  2. The number of cases (and if I were to make the change in #1, loop iterations) is hard-coded. They should be replaced with a constant for more clarity.

Let me know what you think.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, eecsninja said:

Resurrecting an old thread...

I just built 0AD for the first time and saw a bunch of these compiler warnings:


../../../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;
                            ~~~^~~~~

To get my feet wet with 0AD, I think I can rewrite the code to avoid these warnings and be a little cleaner.

  1. These break-less case statements are all repetitive. I could replace them with for loops.
  2. The number of cases (and if I were to make the change in #1, loop iterations) is hard-coded. They should be replaced with a constant for more clarity.

Let me know what you think.

We need the warnings.

 

Link to comment
Share on other sites

4 hours ago, eecsninja said:

^^^

I can't tell why we need the warnings when I read over the thread. What's the reason?

Hey @eecsninja

Have you read on how to contribute yet ? If not I'd suggest your read GettingStartedProgrammers and SubmittingPatches on trac.wildfiregames.com I can't promise your changes will make it to the game but they are most likely welcome. 

Regards,

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

For what it's worth, the warnings above for AtlasObjectXML.cpp concerning the implicit fallthroughs should no longer occur as the code has been rewritten to no longer need the break-less switch...case statements at all.

@eecsninja, thank you for your patch. It is unfortunate that it wasn't included (due to it being superseded by work being undertaken pursuing another objective), but we appreciate the effort ;).

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...