Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang compiling warnings #406

Closed
wolfy1339 opened this issue Apr 24, 2017 · 2 comments
Closed

clang compiling warnings #406

wolfy1339 opened this issue Apr 24, 2017 · 2 comments

Comments

@wolfy1339
Copy link
Contributor

wolfy1339 commented Apr 24, 2017

To replicate,

export CC=clang
export CXX=clang++
scons --lin --64bit (lua, --luajit and --nolua) --debugging

Note that some warnings are duplicated accross the configurations

With --luajit and --debugging

In file included from src/gui/interface/Label.cpp:8:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/SaveButton.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/Textbox.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/preview/PreviewController.cpp:3:
src/gui/preview/PreviewController.h:15:6: warning: private field 'saveDate' is not used [-Wunused-private-field]
        int saveDate;
            ^
1 warning generated.
src/gui/profile/ProfileActivity.cpp:79:21: warning: private field 'a' is not used [-Wunused-private-field]
                ProfileActivity * a;
                                  ^
1 warning generated.

With --nolua and --debugging

In file included from src/client/GameSave.cpp:9:
src/bson/BSON.h:1195:24: warning: unused function 'bson_swap_endian64' [-Wunused-function]
static TPT_INLINE void bson_swap_endian64( void *outp, const void *inp ) {
                       ^
src/bson/BSON.h:1209:24: warning: unused function 'bson_swap_endian32' [-Wunused-function]
static TPT_INLINE void bson_swap_endian32( void *outp, const void *inp ) {
                       ^
2 warnings generated.
src/debug/ParticleDebug.cpp:33:11: warning: variable 'i' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        else if (mode == 1)
                 ^~~~~~~~~
src/debug/ParticleDebug.cpp:51:46: note: uninitialized use occurs here
        sim->UpdateParticles(debug_currentParticle, i);
                                                    ^
src/debug/ParticleDebug.cpp:33:7: note: remove the 'if' if its condition is always true
        else if (mode == 1)
             ^~~~~~~~~~~~~~
src/debug/ParticleDebug.cpp:18:7: note: initialize the variable 'i' to silence this warning
        int i;
             ^
              = 0
1 warning generated.
src/resampler/resampler.cpp:342:28: warning: unused variable 'KAISER_ALPHA' [-Wunused-const-variable]
static const Resample_Real KAISER_ALPHA = 4.0;
                           ^
1 warning generated.
src/lua/TPTScriptInterface.cpp:52:5: warning: variable 'retCode' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        if(commandWords.size())
           ^~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:59:9: note: uninitialized use occurs here
        return retCode;
               ^~~~~~~
src/lua/TPTScriptInterface.cpp:52:2: note: remove the 'if' if its condition is always true
        if(commandWords.size())
        ^~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:23:13: note: initialize the variable 'retCode' to silence this warning
        int retCode;
                   ^
                    = 0
src/lua/TPTScriptInterface.cpp:388:12: warning: variable 'type' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                else if (selector.GetType() == TypeString)
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:391:7: note: uninitialized use occurs here
                if (type<0 || type>=PT_NUM)
                    ^~~~
src/lua/TPTScriptInterface.cpp:388:8: note: remove the 'if' if its condition is always true
                else if (selector.GetType() == TypeString)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:385:11: note: initialize the variable 'type' to silence this warning
                int type;
                        ^
                         = 0
In file included from src/lua/TPTScriptInterface.cpp:10:
In file included from src/lua/TPTScriptInterface.h:5:
src/lua/TPTSTypes.h:89:12: warning: private field 'from' is not used [-Wunused-private-field]
        ValueType from;
                  ^
src/lua/TPTSTypes.h:90:12: warning: private field 'to' is not used [-Wunused-private-field]
        ValueType to;
                  ^
4 warnings generated.
src/simulation/Simulation.cpp:1969:5: warning: address of array 'this->fvx' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if(fvx)
        ~~ ^~~
src/simulation/Simulation.cpp:1971:5: warning: address of array 'this->fvy' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if(fvy)
        ~~ ^~~
2 warnings generated.
src/gui/game/GameController.cpp:1513:84: warning: address of array 'this->gameModel->GetSimulation()->gmenu' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
                if (type == PT_LIFE && ctype >= 0 && ctype < NGOL && gameModel->GetSimulation()->gmenu)
                                                                  ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
src/gui/game/GameController.cpp:1515:70: warning: address of array 'this->gameModel->GetSimulation()->elements' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
                else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements)
                                                    ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
src/gui/game/GameController.cpp:1533:76: warning: address of array 'this->gameModel->GetSimulation()->wtypes' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
        if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
                                                   ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from src/gui/game/GameController.cpp:38:
In file included from src/lua/TPTScriptInterface.h:5:
src/lua/TPTSTypes.h:89:12: warning: private field 'from' is not used [-Wunused-private-field]
        ValueType from;
                  ^
src/lua/TPTSTypes.h:90:12: warning: private field 'to' is not used [-Wunused-private-field]
        ValueType to;
                  ^
src/gui/game/GameView.cpp:1864:14: warning: private field 'v' is not used [-Wunused-private-field]
                GameView * v;
                           ^
5 warnings generated.
1 warning generated.
In file included from src/gui/interface/AvatarButton.cpp:10:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/Component.cpp:7:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/ContextMenu.cpp:1:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
In file included from src/gui/interface/ContextMenu.cpp:1:
src/gui/interface/ContextMenu.h:23:7: warning: private field 'isMouseInside' is not used [-Wunused-private-field]
        bool isMouseInside;
             ^
2 warnings generated.
In file included from src/gui/interface/Label.cpp:8:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/SaveButton.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/Textbox.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/preview/PreviewController.cpp:3:
src/gui/preview/PreviewController.h:15:6: warning: private field 'saveDate' is not used [-Wunused-private-field]
        int saveDate;
            ^
1 warning generated.
src/gui/profile/ProfileActivity.cpp:79:21: warning: private field 'a' is not used [-Wunused-private-field]
                ProfileActivity * a;
                                  ^
1 warning generated.

Normal debugging build

In file included from src/bson/BSON.cpp:24:
src/bson/BSON.h:1195:24: warning: unused function 'bson_swap_endian64' [-Wunused-function]
static TPT_INLINE void bson_swap_endian64( void *outp, const void *inp ) {
                       ^
1 warning generated.
In file included from src/client/GameSave.cpp:9:
src/bson/BSON.h:1195:24: warning: unused function 'bson_swap_endian64' [-Wunused-function]
static TPT_INLINE void bson_swap_endian64( void *outp, const void *inp ) {
                       ^
src/bson/BSON.h:1209:24: warning: unused function 'bson_swap_endian32' [-Wunused-function]
static TPT_INLINE void bson_swap_endian32( void *outp, const void *inp ) {
                       ^
2 warnings generated.
src/debug/ParticleDebug.cpp:33:11: warning: variable 'i' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        else if (mode == 1)
                 ^~~~~~~~~
src/debug/ParticleDebug.cpp:51:46: note: uninitialized use occurs here
        sim->UpdateParticles(debug_currentParticle, i);
                                                    ^
src/debug/ParticleDebug.cpp:33:7: note: remove the 'if' if its condition is always true
        else if (mode == 1)
             ^~~~~~~~~~~~~~
src/debug/ParticleDebug.cpp:18:7: note: initialize the variable 'i' to silence this warning
        int i;
             ^
              = 0
1 warning generated.

src/lua/LuaScriptInterface.cpp:1852:41: warning: implicit conversion from 'float' to 'lua_Integer' (aka 'long') changes value from 295.14999 to 295
      [-Wliteral-conversion]
        int ambientAirTemp = luaL_optint(l, 1, 295.15f);
                             ~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/lua5.1/lauxlib.h:105:59: note: expanded from macro 'luaL_optint'
#define luaL_optint(L,n,d)      ((int)luaL_optinteger(L, (n), (d)))
                                      ~~~~~~~~~~~~~~~          ^
In file included from src/lua/LuaScriptInterface.cpp:13:
In file included from src/lua/TPTScriptInterface.h:5:
src/lua/TPTSTypes.h:89:12: warning: private field 'from' is not used [-Wunused-private-field]
        ValueType from;
                  ^
src/lua/TPTSTypes.h:90:12: warning: private field 'to' is not used [-Wunused-private-field]
        ValueType to;
                  ^
src/resampler/resampler.cpp:342:28: warning: unused variable 'KAISER_ALPHA' [-Wunused-const-variable]
static const Resample_Real KAISER_ALPHA = 4.0;
                           ^
src/lua/TPTScriptInterface.cpp:52:5: warning: variable 'retCode' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        if(commandWords.size())
           ^~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:59:9: note: uninitialized use occurs here
        return retCode;
               ^~~~~~~
src/lua/TPTScriptInterface.cpp:52:2: note: remove the 'if' if its condition is always true
        if(commandWords.size())
        ^~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:23:13: note: initialize the variable 'retCode' to silence this warning
        int retCode;
                   ^
                    = 0
src/lua/TPTScriptInterface.cpp:388:12: warning: variable 'type' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                else if (selector.GetType() == TypeString)
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:391:7: note: uninitialized use occurs here
                if (type<0 || type>=PT_NUM)
                    ^~~~
src/lua/TPTScriptInterface.cpp:388:8: note: remove the 'if' if its condition is always true
                else if (selector.GetType() == TypeString)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lua/TPTScriptInterface.cpp:385:11: note: initialize the variable 'type' to silence this warning
                int type;
                        ^
                         = 0
1 warning generated.
In file included from src/lua/TPTScriptInterface.cpp:10:
In file included from src/lua/TPTScriptInterface.h:5:
src/lua/TPTSTypes.h:89:12: warning: private field 'from' is not used [-Wunused-private-field]
        ValueType from;
                  ^
src/lua/TPTSTypes.h:90:12: warning: private field 'to' is not used [-Wunused-private-field]
        ValueType to;
                  ^
3 warnings generated.

4 warnings generated.

src/simulation/Simulation.cpp:1969:5: warning: address of array 'this->fvx' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if(fvx)
        ~~ ^~~
src/simulation/Simulation.cpp:1971:5: warning: address of array 'this->fvy' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if(fvy)
        ~~ ^~~

2 warnings generated.
src/gui/game/GameController.cpp:1513:84: warning: address of array 'this->gameModel->GetSimulation()->gmenu' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
                if (type == PT_LIFE && ctype >= 0 && ctype < NGOL && gameModel->GetSimulation()->gmenu)
                                                                  ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
src/gui/game/GameController.cpp:1515:70: warning: address of array 'this->gameModel->GetSimulation()->elements' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
                else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements)
                                                    ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
src/gui/game/GameController.cpp:1533:76: warning: address of array 'this->gameModel->GetSimulation()->wtypes' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
        if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
                                                   ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
src/gui/game/GameView.cpp:1864:14: warning: private field 'v' is not used [-Wunused-private-field]
                GameView * v;
                           ^
3 warnings generated.
1 warning generated.

In file included from src/gui/interface/AvatarButton.cpp:10:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/Component.cpp:7:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
In file included from src/gui/interface/ContextMenu.cpp:1:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
clang: warning: optimization flag '-funsafe-loop-optimizations' is not supported
In file included from src/gui/interface/ContextMenu.cpp:1:
src/gui/interface/ContextMenu.h:23:7: warning: private field 'isMouseInside' is not used [-Wunused-private-field]
        bool isMouseInside;
             ^
clang: warning: optimization flag '-funsafe-loop-optimizations' is not supported
2 warnings generated.
clang: warning: optimization flag '-funsafe-loop-optimizations' is not supported
In file included from src/gui/interface/Label.cpp:8:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/SaveButton.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.
In file included from src/gui/interface/Textbox.cpp:11:
src/gui/interface/ContextMenu.h:29:15: warning: 'ui::ContextMenu::ActionCallback' hides overloaded virtual function [-Woverloaded-virtual]
        virtual void ActionCallback(ui::Button *sender, int item);
                     ^
src/gui/interface/Button.h:15:15: note: hidden overloaded virtual function 'ui::ButtonAction::ActionCallback' declared here: different number of parameters
      (1 vs 2)
        virtual void ActionCallback(ui::Button * sender) {}
                     ^
1 warning generated.

In file included from src/gui/preview/PreviewController.cpp:3:
src/gui/preview/PreviewController.h:15:6: warning: private field 'saveDate' is not used [-Wunused-private-field]
        int saveDate;
            ^
1 warning generated.
src/gui/profile/ProfileActivity.cpp:79:21: warning: private field 'a' is not used [-Wunused-private-field]
                ProfileActivity * a;
                                  ^
@wolfy1339 wolfy1339 changed the title clang compile warnings clang compiling warnings Apr 24, 2017
@jacob1
Copy link
Member

jacob1 commented Apr 28, 2017

The first warning in bson.h is totally invalid ... and there's no way to get rid of it without a hack. Hopefully the rest are valid.

@jacob1 jacob1 closed this as completed in cdc8f64 Apr 28, 2017
@jacob1
Copy link
Member

jacob1 commented Apr 28, 2017

Fixed. I was able to fix that one warning in a non-hacky way. Most warnings were pretty pointless but everything is technically more correct now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants