Visual Studio warnings

  • 3 Replies
  • 92 Views
Visual Studio warnings
« on: 18 September 2019, 17:09:32 »
It is good to have a project compile with no errors and warnings. But sometimes third party libraries introduce warning messages into our projects and so is the case with TGUI.
I think you should build the library in Visual Studio because it provides serious warnings as well that are ought to be noticed. One of the four warnings I'm currently getting says "Dereferencing NULL pointer mOwner" inside CopiedPtr.hpp line 121, which I guess, can prove fatal during runtime!
I hope these issues will be solved in an upcoming version of this library so that the developers can build their projects without worrying about the warnings that are produced while compiling such libraries.

Re: Visual Studio warnings
« Reply #1 on: 18 September 2019, 19:29:07 »
It's seems as false positive. mOwner can't be dereferencing with null  here because it initialize with same condition as mOwner itself.

But are you sure that you use latest version of compiler because I didn't get it for VS 16.2.5.

Re: Visual Studio warnings
« Reply #2 on: 19 September 2019, 09:20:23 »
hi, compiling with vs 2019 16.2.5 , 10.0.18362.0 sdk version and Level4 (/W4) warning level, i have the following warnings.

Quote
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\xutility(2866,22): warning C4389:  '==': signed/unsigned mismatch

Quote
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :  see reference to function template instantiation 'int std::count<sf::String::Iterator,char>(const _InIt,const _InIt,const _Ty &)' being compiled
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :         with
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :         [
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :             _InIt=sf::String::Iterator,
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :             _Ty=char
2>D:\Pandora\ThirdParty\TGUI-0.8\src\TGUI\Widgets\Label.cpp(625): message :         ]

Quote
3>D:\Pandora\ThirdParty\TGUI-0.8\gui-builder\include\WidgetProperties/EditBoxProperties.hpp(44,56): warning C4244:  'argument': conversion from 'sf::Uint32' to 'char', possible loss of data

*

texus

  • *****
  • 1475
    • View Profile
    • Texus's Blog
Re: Visual Studio warnings
« Reply #3 on: 19 September 2019, 19:19:08 »
I am aware that VS gives some warnings, this will often be the case. Occasionally I do fix those VS warnings (usually right before I release a new patch version), but because I work on linux with gcc I only see the warnings given by gcc. If a warning is serious then it is likely that gcc will also the warning, so the warnings that do occur are usually about int/float or signed/unsigned mismatches. I do care about these things, I wish that gcc showed them too in which case I would fix them immediately, but I'm not going to constantly check the windows logs just to see if there is any minor warning.

I also rely on unit tests to find code issues. I've had windows tests failing on multiple occasions while everything passed on linux, but I have never encountered any bug that got through those tests but would have been fixed if I had gotten these few extra warnings. This is why I consider them mostly harmless. That being said, I do prefer it if my projects build without any warnings at all on all compilers, even if the warnings aren't important, so I will probably fix them this weekend or so unless someone sends a PR before that time. (The one in CopiedPtr.hpp isn't going to be fixed, it is a false positive and it also isn't part of TGUI but part of the external Aurora library)

It has been longer than usual since the last patch release, which is also why it is longer than usual since I built with VS.
« Last Edit: 19 September 2019, 19:21:21 by texus »