Skip to content

Commit 01d7279

Browse files
committed
suppress erroneous buffer-overrun warning in msvc
The msvc optimizer runs into a bug in the mutable lambda tests for move_only_function where it believes we're placing a large object into the small buffer, resulting in compiler errors: D:\a\compat\boost-root\boost\compat\move_only_function.hpp(400) : error C2220: the following warning is treated as an error D:\a\compat\boost-root\boost\compat\move_only_function.hpp(400) : warning C4789: in function 'void __cdecl test_mutable_lambda(void)' buffer 'func2' of size 32 bytes will be overrun; 256 bytes will be written starting at offset 0 The code, however, is correct and eschews the SBO path for sufficiently large Callables, as if one manually adds a `throw 1234;` statement to the SBO paths, they are not hit when the test case in question is run. We choose to manually suppress the warning as no other compiler emits it nor is it found by any of our sanitizer CI jobs, including locally.
1 parent 945b286 commit 01d7279

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/move_only_function_test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
# pragma clang diagnostic ignored "-Wself-move"
2727
#endif
2828

29+
#ifdef _MSC_VER
30+
#pragma warning(disable: 4789) // false buffer overrun warning in test_mutable_lambda()
31+
#endif
32+
2933
using std::is_same;
3034
using std::is_constructible;
3135
using std::is_nothrow_constructible;

0 commit comments

Comments
 (0)