Skip to content

std::uncaught_exception() is deprecated in C++17 #21

Open
@maddouri

Description

Hi Mat,

I'm getting the following warning from MSVC 2017 when compiling in C++17 mode (i.e. using the /std:c++17 flag)

2> ... xeumeuleu/streams/xofstream.hpp(84): warning C4996: 'std::uncaught_exception': warning STL4006: std::uncaught_exception() is deprecated in C++17. It is superseded by std::uncaught_exceptions(), plural. You can define _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\exception(17): note: see declaration of 'std::uncaught_exception'

As mentioned in the message, I did get rid of the warning when defining _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING. However, I think that this should be fixed in the library.

If it's not much trouble, could please have a look at it?

ps: here's a minimal code sample for reproducing the problem:

main.cpp

#include <xeumeuleu/xml.hpp>

int main()
{
    xml::xifstream xif("some_file.xml");
    (void) xif;

    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

project(xeumeuleu_warning)

add_executable(xeumeuleu_warning main.cpp)

target_include_directories(xeumeuleu_warning PRIVATE
    "path/to/xercesc/include"
    "path/to/xeumeuleu/include"
)

target_link_libraries(xeumeuleu_warning "path/to/xercesc.lib")

target_compile_options(xeumeuleu_warning PRIVATE /std:c++17 /W4 /WX)

#target_compile_definitions(xeumeuleu_warning PRIVATE _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING)

Compiling Instructions

cmake -G"Visual Studio 15 2017 Win64" -H. -Bbuild
cmake --build build --config Release

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions