Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Unittest generates warning with C++17 regarding auto_ptr #335

@NeroBurner

Description

@NeroBurner

When compiling with C++17 enabled gcc throws the following warning:

[ 76%] Building CXX object CMakeFiles/utilities_unittest.dir/src/utilities_unittest.cc.obj
/usr/src/app/src/logging_unittest.cc: In function 'void TestDCHECK()':
/usr/src/app/src/logging_unittest.cc:575:3: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   auto_ptr<int64> sptr(new int64);
   ^~~~~~~~
In file included from /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/include/c++/bits/locale_conv.h:41:0,
                 from /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/include/c++/locale:43,
                 from /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/include/c++/iomanip:43,
                 from /usr/src/app/src/logging_unittest.cc:44:
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/include/c++/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~

For a full build output see the following log: https://travis-ci.org/NeroBurner/glog/jobs/399043400

With MSVC 2017 and C++17 enabled the build throws an error (full log https://ci.appveyor.com/project/NeroBurner/glog/build/1.0.111/job/dl21jws89k12c66u#L266)

ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\CL.exe /c /I"C:\projects\glog\_build_vs-15-2017-win64-cxx17_Debug" /IC:\projects\glog\src /IC:\projects\glog\src\windows /I"C:\Tools\vcpkg\installed\x64-windows\include" /Zi /nologo /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D GLOG_NO_ABBREVIATED_SEVERITIES /D GOOGLE_GLOG_DLL_DECL= /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"logging_unittest.dir\Debug\\" /Fd"logging_unittest.dir\Debug\vc141.pdb" /Gd /TP /FC /errorReport:queue C:\projects\glog\src\logging_unittest.cc
  logging_unittest.cc
c:\projects\glog\src\logging_unittest.cc(575): error C2065: 'auto_ptr': undeclared identifier [C:\projects\glog\_build_vs-15-2017-win64-cxx17_Debug\logging_unittest.vcxproj]

edit: Just using unique_ptr fixes the warning and compilation for C++11 and above, but breaks the test for C++98 and below

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions