Closed dharesign closed 4 years ago
Note that internally we determined that it was due to an alignas
. If the alignas
is removed, the problem goes away.
https://gist.github.com/dharesign/25b0d324ba48314eb4c683910c7b199f is a complete test case that simplifies out all of the BDE code.
Note that removing MemFn
(and thus storing a ConPxy<FN>
in Bound
) also makes the problem go away.
Even shorter version showing the same issue: https://godbolt.org/z/MGFFRB. The generated code for void f(S)
in /Ob0
has a _memcpy
before calling S::~S
.
I believe this issue was addressed via internal PR. Closing.
Overview
There seems to be erroneous code generation in MSVC 2019 (and 2017), when compiling the following code with
/Ob0
: https://github.com/dharesign/bde/commit/0ebd79270f828db82c233b86276c96ff883ea113The code appears to end up
memcpy
-ing absl::map
object, resulting in its internal state (pointers to heap objects) being invalid.When compiling with
/Ob1
the issue goes away: https://github.com/dharesign/bde-tools/commit/140dd5b4a94533a1312e70c76f6f007955d73528The code posted is a minimal example of the issue. The
Derived
class appears to need two base classes for the issue to occur. The bound function needs to be a member function. A similar free function taking aDerived *
as the first parameter doesn't exhibit the crash.Using native
std::bind
doesn't crash.To Reproduce
With MSVC 2019, CMake, and Git Bash installed:
The test fails with an access violation:
The following works around the crash: