Andrew Truckle
Andrew Truckle

Reputation: 19087

Warnings in Visual Studio2019 compiling with Boost 1.75

Just upgraded Visual Studio and did a full recompile of my project. Now get some warnings concerning boost:

5>D:\My Libraries\Boost\boost_1_75_0\boost\concept_check.hpp(355,12): warning C4834: discarding return value of function with 'nodiscard' attribute
5>D:\My Libraries\Boost\boost_1_75_0\boost\concept_check.hpp(354): message : while compiling class template member function 'void boost::BinaryFunction<Func,Return,First,Second>::test(boost::false_type)'
5>        with
5>        [
5>            Func=std::less<CString>,
5>            Return=bool,
5>            First=ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>,
5>            Second=ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>
5>        ]

I see several compiler warnings now that did not appear before.

I should clarify that these warnings only appear in Release x86 builds (MFC Unicode MD). The x64 Release build is OK.

Upvotes: 0

Views: 443

Answers (1)

Kaldrr
Kaldrr

Reputation: 2850

It's a known issue, newest version of Visual Studio added [[nodiscard]] attribute to std::equal_to. The issue has been submitted to boost already https://github.com/boostorg/concept_check/issues/31.

For now, you can fix it by temporarily modify boost/concept_check.hpp file yourself.

  BOOST_concept(BinaryFunction,(Func)(Return)(First)(Second))
  {
      BOOST_CONCEPT_USAGE(BinaryFunction) { test(is_void<Return>()); }
   private:
      void test(boost::false_type)
      {
          (void)f(first,second); // add (void) here to silence the warning
          Return r = f(first, second); // require operator()
          (void)r;
      }

Or you could add #pragma warning(disable : 4834) before including that file, to disable that warning.

Upvotes: 4

Related Questions