diff --git a/include/nlohmann/optional.hpp b/include/nlohmann/optional.hpp index 563897625..dee4d4b5b 100644 --- a/include/nlohmann/optional.hpp +++ b/include/nlohmann/optional.hpp @@ -86,7 +86,10 @@ class optional return std::move(base_value); } - constexpr optional() noexcept(noexcept(std::optional())) = default; + constexpr optional() noexcept(noexcept(std::optional())) + : base_value() // explicitly initialized to mitigate -Werror=effc++ + { + } constexpr optional(std::nullopt_t /* unused */) noexcept : base_value(std::nullopt) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a02d2a6c5..b2d4f1e48 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4678,7 +4678,10 @@ class optional return std::move(base_value); } - constexpr optional() noexcept(noexcept(std::optional())) = default; + constexpr optional() noexcept(noexcept(std::optional())) + : base_value() // explicitly initialized to mitigate -Werror=effc++ + { + } constexpr optional(std::nullopt_t /* unused */) noexcept : base_value(std::nullopt)