Skip to content

Commit

Permalink
🔨 Suppress bad unreachable diagnostic
Browse files Browse the repository at this point in the history
MSVC somehow determines that some code is "unreachable" despite
actually being reachable code.

The bad diagnostics have been suppressed.
  • Loading branch information
bitwizeshift committed Jul 19, 2020
1 parent a14b276 commit 3ca0cd5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/bpstd/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE \
__pragma(warning(push)) \
__pragma(warning(disable:4714)) \
__pragma(warning(disable:4100))
__pragma(warning(disable:4100))
#else
# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE
#endif
Expand Down
11 changes: 10 additions & 1 deletion include/bpstd/detail/variant_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,26 @@ bpstd::detail::variant_base<false,Types...>::variant_base()

}

#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable:4702)
#endif

template <typename...Types>
template <std::size_t N, typename...Args>
inline BPSTD_INLINE_VISIBILITY constexpr
bpstd::detail::variant_base<false,Types...>::variant_base(variant_index_tag<N>,
Args&&...args)
Args&&...args)
: m_union{variant_index_tag<N>{}, std::forward<Args>(args)...},
m_index{N}
{

}

#if defined(_MSC_VER)
# pragma warning(pop)
#endif

//------------------------------------------------------------------------------

template <typename...Types>
Expand Down
8 changes: 8 additions & 0 deletions test/src/bpstd/variant.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
SOFTWARE.
*/

// MSVC 2015 seems to emit "unreachable code" diagnostics in the wrong function
// whenever a function is inlined. The error will not be seen in the inlined
// function, but it may be seen in the surrounding scope of the inlined function
#if defined(_MSC_VER)
# pragma warning(disable:4702)
#endif

#include <bpstd/variant.hpp>
#include <bpstd/memory.hpp>

Expand All @@ -37,6 +44,7 @@
// stupid reason.
#if defined(_MSC_VER)
# pragma warning(disable:4714)
# pragma warning(disable:4702)
#endif

static_assert(
Expand Down

0 comments on commit 3ca0cd5

Please sign in to comment.