new compiler warnings for master with recent MSVC

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

new compiler warnings for master with recent MSVC

Post by uwestoehr »

I only installed the monthly MSVC 2019 update and get now more than 500 compiler warnings. Maybe they changed what warnings I get since before there were "only" about 200. However, many are for external libraries of the LibPack, but some are in our code.

As always, I only post them for information. I have no clue if we need to act and if so how.

Here the warnings grouped by type:

Type A: C26495

Code: Select all

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C26495	Variable 'App::PropertyData::parentPropertyData' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\App\PropertyContainer.h	136	
Warning	C26495	Variable 'PartDesign::Hole::CutDimensionSet::thread_type' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	157	
Warning	C26495	Variable 'PartDesign::Hole::CutDimensionSet::cut_type' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	157	
Warning	C26495	Variable 'PartDesign::Hole::CutDimensionSet::angle' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.cpp	1602	
Warning	C26495	Variable 'PartDesign::Hole::CutDimensionSet::angle' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.cpp	1608	
Warning	C26495	Variable 'PartDesign::Hole::CutDimensionSet::angle' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	157	
Warning	C26495	Variable 'PartDesign::Hole::CounterSinkDimension::diameter' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	149	
Warning	C26495	Variable 'PartDesign::Hole::CounterBoreDimension::diameter' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	143	
Warning	C26495	Variable 'PartDesign::Hole::CounterBoreDimension::depth' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.h	143	
Warning	C26495	Variable 'Part::ShapeHistory::type' is uninitialized. Always initialize a member variable (type.6).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\PropertyTopoShape.h	108	
Type B: C26439

Code: Select all

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\App\ObjectIdentifier.h	92	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\App\ObjectIdentifier.h	158	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\App\ObjectIdentifier.h	255	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	95	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	168	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	186	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	204	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	224	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	245	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	280	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	295	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	315	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	336	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	352	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	367	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	383	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	398	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	414	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	430	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	442	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	454	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	470	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	486	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	502	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	517	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	533	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	549	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	566	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	581	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	596	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	612	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	628	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	644	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	661	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Exception.h	679	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Base\Interpreter.h	148	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\Attacher.h	470	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\AttachExtension.h	56	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\TopoShape.h	56	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\TopoShape.h	69	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesignGui	D:\FreeCADGit\src\Gui\Selection.h	135	
Warning	C26439	This kind of function may not throw. Declare it 'noexcept' (f.6).	PartDesignGui	D:\FreeCADGit\src\Gui\Selection.h	139	
Type C: C2681

Code: Select all

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C26812	The enum type 'TechDraw::GeomType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	TechDraw	D:\FreeCADGit\src\Mod\TechDraw\App\Geometry.h	129	
Warning	C26812	The enum type 'TechDraw::ExtractionType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	TechDraw	D:\FreeCADGit\src\Mod\TechDraw\App\Geometry.h	129	
Warning	C26812	The enum type 'TechDraw::edgeClass' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	TechDraw	D:\FreeCADGit\src\Mod\TechDraw\App\Geometry.h	129	
Warning	C26812	The enum type 'SoVectorizeAction::DimensionUnit' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCAD-build\FreeCADLibs_12.4.2_x64_VC17\include\Inventor\annex\HardCopy\SoVectorizeAction.h	131	
Warning	C26812	The enum type 'SoMultiTextureImageElement::Wrap' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCAD-build\FreeCADLibs_12.4.2_x64_VC17\include\Inventor\elements\SoMultiTextureImageElement.h	184	
Warning	C26812	The enum type 'SoMultiTextureImageElement::Model' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCAD-build\FreeCADLibs_12.4.2_x64_VC17\include\Inventor\elements\SoMultiTextureImageElement.h	184
Warning	C26812	The enum type 'PyGILState_STATE' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Base\Interpreter.h	167	
Warning	C26812	The enum type 'PartDesign::Hole::CutDimensionSet::ThreadType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.cpp	1535	
Warning	C26812	The enum type 'PartDesign::Hole::CutDimensionSet::CutType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.cpp	1602	
Warning	C26812	The enum type 'PartDesign::FeatureAddSub::Type' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Mod\PartDesign\App\FeatureHole.cpp	546	
Warning	C26812	The enum type 'Gui::ViewStatus' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\ViewProvider.h	373	
Warning	C26812	The enum type 'Gui::TaskView::TaskDialog::ButtonPosition' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\TaskView\TaskDialog.h	57	
Warning	C26812	The enum type 'Gui::SelectionChanges::MsgType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\Selection.h	83	
Warning	C26812	The enum type 'Gui::MDIView::ViewMode' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\MDIView.h	113	
Warning	C26812	The enum type 'Gui::FileChooser::AcceptMode' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\FileDialog.h	182	
Warning	C26812	The enum type 'Gui::Command::TriggerSource' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesignGui	D:\FreeCADGit\src\Gui\Command.h	356	
Warning	C26812	The enum type 'Base::QuantityFormat::NumberFormat' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Base\Quantity.h	97	
Warning	C26812	The enum type 'Base::PyStreambuf::Type' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Base\Stream.h	259	
Warning	C26812	The enum type 'Attacher::eRefType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\Mod\Part\App\Attacher.h	384	
Warning	C26812	The enum type 'App::Property::Status' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\App\Property.h	205	
Warning	C26812	The enum type 'App::ObjectStatus' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\App\DocumentObject.h	176	
Warning	C26812	The enum type 'App::ObjectIdentifier::Component::typeEnum' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\App\ObjectIdentifier.h	160	
Warning	C26812	The enum type 'App::Material::MaterialType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	PartDesign	D:\FreeCADGit\src\App\Material.h	273	
Warning	C26812	The enum type '?A0x6a5bdc34::DrawViewType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).	TechDraw	D:\FreeCADGit\src\Mod\TechDraw\App\DrawViewDimension.cpp	198	
Type D: C26451

Code: Select all

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C26451	Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).	PartDesign	D:\FreeCADGit\src\zipios++\virtualseeker.h	67	
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: new compiler warnings for master with recent MSVC

Post by wmayer »

I only installed the monthly MSVC 2019 update and get now more than 500 compiler warnings. Maybe they changed what warnings I get since before there were "only" about 200. However, many are for external libraries of the LibPack, but some are in our code.
What are the warnings caused by the libraries?
As always, I only post them for information. I have no clue if we need to act and if so how.
Basically it's good programming practice to fix compiler warnings. However, in the past MSVC produced many false-positives but the warnings you reported here seem to be worth to be fixed.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: new compiler warnings for master with recent MSVC

Post by uwestoehr »

wmayer wrote: Sun Jan 17, 2021 10:37 am What are the warnings caused by the libraries?
They are all one of the same 4 types I listed above. It seems that the MSVC update brought some more checks for different warning types, thus I get more.
the warnings you reported here seem to be worth to be fixed.
OK. Unfortunately I don't have much knowledge about these things. Therefore I cannot help much.
Post Reply