Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/toml++/impl/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,22 @@ TOML_ENABLE_WARNINGS;
/// These compile errors were reported by Kevin Dick, Jan 19, 2024, at https://github.com/marzer/tomlplusplus/issues/219
//# }}

#ifndef TOML_DISABLE_NOEXCEPT_NOEXCEPT
#define TOML_DISABLE_NOEXCEPT_NOEXCEPT 0
#ifdef _MSC_VER
#if _MSC_VER <= 1943 // Up to Visual Studio 2022 Version 17.13.6
#undef TOML_DISABLE_NOEXCEPT_NOEXCEPT
#define TOML_DISABLE_NOEXCEPT_NOEXCEPT 1
#endif
#endif
#endif
//# {{
/// \def TOML_DISABLE_NOEXCEPT_NOEXCEPT
/// \brief Disable using noexcept(noexcept(<expression>)) within the toml++ library implementation.
/// \detail This macro offers a workaround to a bug in Visual C++ (Visual Studio 2022), which caused
/// compile errors, saying: "error C3878: syntax error: unexpected token ',' following 'simple-type-specifier'"
//# }}

/// @}
//#====================================================================================================================
//# CHARCONV SUPPORT
Expand Down
7 changes: 5 additions & 2 deletions include/toml++/impl/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ TOML_NAMESPACE_START
(impl::value_variadic_ctor_allowed<value<ValueType>, impl::remove_cvref<Args>...>::value),
typename... Args)
TOML_NODISCARD_CTOR
explicit value(Args&&... args) noexcept(noexcept(value_type(
impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))))
explicit value(Args&&... args)
#if !TOML_DISABLE_NOEXCEPT_NOEXCEPT
noexcept(noexcept(value_type(
impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))))
#endif
Comment on lines -269 to +273
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only use of noexcept(noexcept(<expression>)) in toml++, and while a regular MSVC build appears to be able to parse it, it fails when using the tomlplusplus module (doing a C++20 compilation).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, MSVC does compile noexcept(noexcept(<expression>)) in other situations. I don't know exactly in which particular situations noexcept(noexcept(<expression>)) triggers an error, but this is one of them 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still "Draft" because I haven't yet figured out if this is a known compiler bug. Otherwise, maybe it should be reported!

The added value of this particular noexcept specifier looks rather small, right? 🤷 So then, is it OK to put it inside an #if ... #endif?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmn, might be able to work around this by extracting the inner noexcept() out into a separate typedef or template variable, then using that in the outer noexcept()?

Otherwise yeah I'm OK with a switch to turn it off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feeling is that the combination of variadic templates + noexcept(noexcept(...)) + modules is more than MSVC can handle. You can use each feature, just don't combine them 😸

: val_(impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))
{
#if TOML_LIFETIME_HOOKS
Expand Down
17 changes: 15 additions & 2 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,16 @@ TOML_ENABLE_WARNINGS;
#define TOML_DISABLE_CONDITIONAL_NOEXCEPT_LAMBDA 0
#endif

#ifndef TOML_DISABLE_NOEXCEPT_NOEXCEPT
#define TOML_DISABLE_NOEXCEPT_NOEXCEPT 0
#ifdef _MSC_VER
#if _MSC_VER <= 1943 // Up to Visual Studio 2022 Version 17.13.6
#undef TOML_DISABLE_NOEXCEPT_NOEXCEPT
#define TOML_DISABLE_NOEXCEPT_NOEXCEPT 1
#endif
#endif
#endif

#if !defined(TOML_FLOAT_CHARCONV) && (TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL))
// not supported by any version of GCC or Clang as of 26/11/2020
// not supported by any version of ICC on Linux as of 11/01/2021
Expand Down Expand Up @@ -5088,8 +5098,11 @@ TOML_NAMESPACE_START
(impl::value_variadic_ctor_allowed<value<ValueType>, impl::remove_cvref<Args>...>::value),
typename... Args)
TOML_NODISCARD_CTOR
explicit value(Args&&... args) noexcept(noexcept(value_type(
impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))))
explicit value(Args&&... args)
#if !TOML_DISABLE_NOEXCEPT_NOEXCEPT
noexcept(noexcept(value_type(
impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))))
#endif
: val_(impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))
{
#if TOML_LIFETIME_HOOKS
Expand Down