diff --git a/src/ds/ptrwrap.h b/src/ds/ptrwrap.h index 1de2ae6..ee34cb6 100644 --- a/src/ds/ptrwrap.h +++ b/src/ds/ptrwrap.h @@ -112,8 +112,22 @@ namespace snmalloc /** * all other constructions must be explicit + * + * Unfortunately, MSVC gets confused if an Allocator is instantiated in a + * way that never needs initialization (as our sandbox test does, for + * example) and, in that case, declares this constructor unreachable, + * presumably after some heroic feat of inlining that has also lost any + * semblance of context. See the blocks tagged "CapPtr-vs-MSVC" for where + * this has been observed. */ +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4702) +#endif explicit CapPtr(T* p) : unsafe_capptr(p) {} +#ifdef _MSC_VER +# pragma warning(pop) +#endif /** * Allow static_cast<>-s that preserve bounds but vary the target type. diff --git a/src/test/func/sandbox/sandbox.cc b/src/test/func/sandbox/sandbox.cc index 051e288..97ca1a1 100644 --- a/src/test/func/sandbox/sandbox.cc +++ b/src/test/func/sandbox/sandbox.cc @@ -19,6 +19,8 @@ namespace /** * Helper for Alloc that is never used as a thread-local allocator and so is * always initialised. + * + * CapPtr-vs-MSVC triggering; xref CapPtr's constructor */ bool never_init(void*) { @@ -26,6 +28,8 @@ namespace } /** * Helper for Alloc that never needs lazy initialisation. + * + * CapPtr-vs-MSVC triggering; xref CapPtr's constructor */ void* no_op_init(function_ref) {