[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
Chris Apple via cfe-commits
cfe-commits at lists.llvm.org
Sat May 4 05:48:28 PDT 2024
cjappl wrote:
Possibly another bug here (or user error).
I am trying to see the warnings show up for a simple test program. The clang used in this example is the tip of your branch at time of writing b95964c2570c11d1d80ae6874be5e400f7b504ad
```cpp
#include <cstdlib>
#include <cstdio>
int* process () [[clang::nonblocking]]
{
// THIS MALLOC SHOULD WARN, RIGHT?
int* malloced_data = (int*)std::malloc(sizeof(int));
malloced_data[0] = 7;
return malloced_data;
}
int main()
{
int* y = process();
printf("y[0] = %d\n", y[0]);
return (int)y[0];
}
```
When I run compile and run this code, it runs, with the proper "7" exit code, but does not give me any warnings on compilation.
```
> /Users/topher/code/radsan_cjappl/build/bin/clang++ main.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -Wfunction-effects -Werror
> ./a.out
y[0] = 7
> echo $?
7
```
I highly suspect I'm doing something wrong, but can't figure out what it might be.
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list