[llvm] [llvm] Initialize function_ref callable state (PR #220561)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 06:55:47 PDT 2026
joker-eph wrote:
> Implicit copies shouldn't matter, copying uninitialized data is fine for Valgrind (in fact, it happens all the time, e.g. when copying padding).
Mmmmm other sources disagree: https://github.com/llvm/llvm-project/pull/220561#issuecomment-5509928373
I asked an agent to help me figure out, it argues that:
> implicit copy/assignment performs memberwise operations, including built-in assignment of the scalar callable. Copying an indeterminate scalar member is not equivalent to copying padding: under C++23 it is undefined behavior; current draft wording classifies the corresponding read as erroneous behavior.
Also MSAN complain in the (revised) unit-test without the initialization:
```
Uninitialized bytes in __msan_check_mem_is_initialized at offset 8 inside [0x..., 16)
==...==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 ... in FunctionRefTest_DefaultConstructedCopy_Test::TestBody()
llvm/unittests/ADT/FunctionRefTest.cpp:36:3
SUMMARY: MemorySanitizer: use-of-uninitialized-value
Exiting
```
See https://github.com/llvm/llvm-project/pull/220600
https://github.com/llvm/llvm-project/pull/220561
More information about the llvm-commits
mailing list