Skip to content

Commit 3ca0cd5

Browse files
committed
🔨 Suppress bad unreachable diagnostic
MSVC somehow determines that some code is "unreachable" despite actually being reachable code. The bad diagnostics have been suppressed.
1 parent a14b276 commit 3ca0cd5

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

include/bpstd/detail/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE \
8787
__pragma(warning(push)) \
8888
__pragma(warning(disable:4714)) \
89-
__pragma(warning(disable:4100))
89+
__pragma(warning(disable:4100))
9090
#else
9191
# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE
9292
#endif

include/bpstd/detail/variant_base.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,26 @@ bpstd::detail::variant_base<false,Types...>::variant_base()
190190

191191
}
192192

193+
#if defined(_MSC_VER)
194+
# pragma warning(push)
195+
# pragma warning(disable:4702)
196+
#endif
197+
193198
template <typename...Types>
194199
template <std::size_t N, typename...Args>
195200
inline BPSTD_INLINE_VISIBILITY constexpr
196201
bpstd::detail::variant_base<false,Types...>::variant_base(variant_index_tag<N>,
197-
Args&&...args)
202+
Args&&...args)
198203
: m_union{variant_index_tag<N>{}, std::forward<Args>(args)...},
199204
m_index{N}
200205
{
201206

202207
}
203208

209+
#if defined(_MSC_VER)
210+
# pragma warning(pop)
211+
#endif
212+
204213
//------------------------------------------------------------------------------
205214

206215
template <typename...Types>

test/src/bpstd/variant.test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
SOFTWARE.
2323
*/
2424

25+
// MSVC 2015 seems to emit "unreachable code" diagnostics in the wrong function
26+
// whenever a function is inlined. The error will not be seen in the inlined
27+
// function, but it may be seen in the surrounding scope of the inlined function
28+
#if defined(_MSC_VER)
29+
# pragma warning(disable:4702)
30+
#endif
31+
2532
#include <bpstd/variant.hpp>
2633
#include <bpstd/memory.hpp>
2734

@@ -37,6 +44,7 @@
3744
// stupid reason.
3845
#if defined(_MSC_VER)
3946
# pragma warning(disable:4714)
47+
# pragma warning(disable:4702)
4048
#endif
4149

4250
static_assert(

0 commit comments

Comments
 (0)