[clang] Allow the no_stack_protector attribute on local variables (PR #173311)
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 23 11:08:19 PST 2025
ahatanak wrote:
It's not clear to me whether we should do this only when NRVO is false.
$ cat test.cpp
```
struct S {
S();
int a[4];
};
#ifdef DONTPROTECT1
__attribute__((no_stack_protector))
#endif
S foo1() {
#ifdef DONTPROTECT2
__attribute__((no_stack_protector))
#endif
S s;
return s;
}
```
Should stack protection get disabled in both cases?
$ clang++ -std=c++11 -S -o - -Os f9.cpp -fstack-protector-strong -DDONTPROTECT1=1
$ clang++ -std=c++11 -S -o - -Os f9.cpp -fstack-protector-strong -DDONTPROTECT2=1
https://github.com/llvm/llvm-project/pull/173311
More information about the cfe-commits
mailing list