diff options
author | fanquake <fanquake@gmail.com> | 2021-09-04 10:51:05 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-09-04 10:51:36 +0800 |
commit | f4e12fd50c23875f4b5f272c94449eb81de43d5d (patch) | |
tree | befc5004a5143c1a404692fa3acb4cce4ef19845 /REVIEWERS | |
parent | 5fb6701bdb05f935ab65d8fe0fcc15c12e32d134 (diff) | |
parent | fa7e6c56f58678b310898a158053ee9ff8b27fe7 (diff) | |
download | bitcoin-f4e12fd50c23875f4b5f272c94449eb81de43d5d.tar.xz |
Merge bitcoin/bitcoin#22278: Add LIFETIMEBOUND to CScript where needed
fa7e6c56f58678b310898a158053ee9ff8b27fe7 Add LIFETIMEBOUND to InitializeChainstate (MarcoFalke)
fa5c896724bb359b4b9a3f89580272bfe5980c1b Add LIFETIMEBOUND to CScript where needed (MarcoFalke)
Pull request description:
Without this, stack-use-after-scope can only be detected at runtime with ASan or code review, both of which are expensive.
Use `LIFETIMEBOUND` to turn this error into a compile warning.
See https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound
Example:
```cpp
const CScript a{WITH_LOCK(::cs_main, return CScript{} << OP_0 << OP_1)};
```
Before: (no warning)
After:
```
warning: returning reference to local temporary object [-Wreturn-stack-address]
const CScript a{WITH_LOCK(::cs_main, return CScript{} << OP_0 << OP_1)};
^~~~~~~~~
./sync.h:276:65: note: expanded from macro 'WITH_LOCK'
#define WITH_LOCK(cs, code) [&]() -> decltype(auto) { LOCK(cs); code; }()
^~~~
ACKs for top commit:
theuni:
utACK fa7e6c56f58678b310898a158053ee9ff8b27fe7.
jonatack:
Light ACK fa7e6c56f58678b310898a158053ee9ff8b27fe7 debug build with clang 13, reproduced the example compiler warning in the pull description, and briefly looked at `clang::lifetimebound` support in earlier versions of clang; it is in clang 7 (https://releases.llvm.org/7.0.0/tools/clang/docs/AttributeReference.html#lifetimebound-clang-lifetimebound), did not see references to it in earlier docs
Tree-SHA512: e915acdc4532445205b7703fab61a5d682231ace78ecfb274cb8523ca2bddefd85828f50ac047cfb1afaff92a331f5f7b5a1472539f999e30f7cf8ac8c3222f3
Diffstat (limited to 'REVIEWERS')
0 files changed, 0 insertions, 0 deletions