Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macroizing abort is non-conformant #86

Closed
StephanTLavavej opened this issue Jan 6, 2020 · 1 comment
Closed

Macroizing abort is non-conformant #86

StephanTLavavej opened this issue Jan 6, 2020 · 1 comment

Comments

@StephanTLavavej
Copy link

This code is non-conformant and fails to compile with the current development version of Visual Studio:

namespace std { inline void ignore_abort(){ std::exit(0); } }
#define abort ignore_abort
//[getting_started_assert_handlers
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER is defined for the whole project
#include <stdexcept> // std::logic_error
#include <iostream> // std::cerr

First, implementing ignore_abort in namespace std is forbidden by N4842 16.5.4.2.1 [namespace.std]/1: "Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std."

Second, macroizing abort is extremely forbidden by 16.5.4.3.2 [macro.names]/1: "A translation unit that includes a standard library header shall not #define or #undef names declared in any standard library header."

Third, this is failing to compile for the current development version of MSVC's STL because including <iostream> drags in <istream>, <ostream>, <ios>, internal <xlocnum>, and finally <cmath> where our implementation of lerp() contains a call to ::abort() which is broken by the macroized abort: https://github.com/microsoft/STL/blob/94c9f9965b4e39bab9fdec6f71f1fad320e96d8b/stl/inc/cmath#L1379-L1380

The assert_handler.cpp example should be changed to follow the Standard's requirements.

@apolukhin
Copy link
Member

Fixed in 178d287, merged to master.

Sorry for the mess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants