Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

MSVC static code analysis warnings

Open ScottHutchinson opened this issue 5 years ago • 5 comments

catch.hpp(11784): warning C26439: This kind of function may not throw. Declare it 'noexcept' (f.6). catch.hpp(4405): warning C26495: Variable 'Catch::Option::storage' is uninitialized. Always initialize a member variable (type.6). catch.hpp(8973): warning C26495: Variable 'Catch::clara::detail::ResultValueBaseCatch::clara::detail::ParseState::::m_value' is uninitialized. Always initialize a member variable (type.6). catch.hpp(8971): warning C26495: Variable 'Catch::clara::detail::ResultValueBaseCatch::clara::detail::ParseState::::m_value' is uninitialized. Always initialize a member variable (type.6). catch.hpp(5833): warning C26415: Smart pointer parameter 'node' is used only to access contained pointer. Use T* or T& instead (r.30). catch.hpp(5833): warning C26418: Shared pointer parameter 'node' is not copied or moved. Use T* or T& instead (r.36). catch.hpp(8860): warning C26495: Variable 'Catch::clara::detail::Token::type' is uninitialized. Always initialize a member variable (type.6). catch.hpp(5529): warning C26439: This kind of function may not throw. Declare it 'noexcept' (f.6).

Platform information:

  • OS: Windows 10 (1909) / Windows Server 2016 (1607)
  • Compiler+version: MSVC 14.26.28801 (VS2019 version 16.6.1)
  • Catch v2.12.2

ScottHutchinson avatar Jun 09 '20 15:06 ScottHutchinson

We are currently disabling warnings like this:

#ifdef _MSC_VER // hutch: 09/17/2020. manually added pending resolution of https://github.com/catchorg/Catch2/issues/1955
#pragma warning(push)
#pragma warning(disable: 26415 26418 26439 26495)
#endif

...

#ifdef _MSC_VER // hutch: 09/17/2020. manually added pending resolution of https://github.com/catchorg/Catch2/issues/1955
#pragma warning(pop)
#endif

ScottHutchinson avatar Jan 21 '21 17:01 ScottHutchinson

Should this issue be closed?

codeinred avatar Oct 11 '21 07:10 codeinred

I'll try to verify tomorrow that this issue has been fixed when running the latest Catch2 and VS2019 version 16.11.3. But I have no reason to think they have been fixed.

ScottHutchinson avatar Oct 11 '21 16:10 ScottHutchinson

This has still not been fixed in Catch v2.13.8, so please leave it open.

ScottHutchinson avatar Feb 22 '22 17:02 ScottHutchinson

I am also seeing rather many warnings with catch 2.13.8: image

Is there any workaround known to disable these in Visual Studio?

s-geiger-si avatar May 31 '23 20:05 s-geiger-si