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

FMT_NOEXCEPT should not depend on FMT_EXCEPTIONS #801

Closed
qis opened this issue Jul 5, 2018 · 3 comments
Closed

FMT_NOEXCEPT should not depend on FMT_EXCEPTIONS #801

qis opened this issue Jul 5, 2018 · 3 comments

Comments

@qis
Copy link
Contributor

qis commented Jul 5, 2018

As the title suggests, FMT_NOEXCEPT should not depend on FMT_EXCEPTIONS.

This will allow std::is_nothrow_* traits to detect the actual behavior properly and things like std::move_if_noexcept to work the same way in both, normal and -fno-exceptions builds.

diff --git i/include/fmt/core.h w/include/fmt/core.h
index 1303f55..96a98f9 100644
--- i/include/fmt/core.h
+++ w/include/fmt/core.h
@@ -131,11 +131,7 @@
 #endif

 #ifndef FMT_NOEXCEPT
-# if FMT_EXCEPTIONS
 #  define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT
-# else
-#  define FMT_NOEXCEPT
-# endif
 #endif

 // This is needed because GCC still uses throw() in its headers when exceptions
@EricWF
Copy link
Contributor

EricWF commented Jul 5, 2018

FMT_DETECTED_NOEXCEPT is sometimes defined to throw(). I don't think you want to add throw() when exceptions are disabled but noexcept is not available (If only because noexcept traits and metaprogramming are only available when noexcept is).

@qis
Copy link
Contributor Author

qis commented Jul 5, 2018

@EricWF So the default FMT_NOEXCEPT value should also depend on noexcept support?

diff --git i/include/fmt/core.h w/include/fmt/core.h
index 1303f55..5488934 100644
--- i/include/fmt/core.h
+++ w/include/fmt/core.h
@@ -126,12 +126,14 @@
     (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \
     FMT_MSC_VER >= 1900
 # define FMT_DETECTED_NOEXCEPT noexcept
+# define FMT_HAS_NOEXCEPT 1
 #else
 # define FMT_DETECTED_NOEXCEPT throw()
+# define FMT_HAS_NOEXCEPT 0
 #endif

 #ifndef FMT_NOEXCEPT
-# if FMT_EXCEPTIONS
+# if FMT_EXCEPTIONS || FMT_FMT_HAS_NOEXCEPT
 #  define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT
 # else
 #  define FMT_NOEXCEPT

@vitaut
Copy link
Contributor

vitaut commented Jul 5, 2018

Could you submit a PR?

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

3 participants