Open
Description
Like with other diagnostics it's possible to control -Wunsafe-buffer-usage
with #pragma clang diagnostic
within a source file. However, there's a weird nonlocal effect: for any instances of the warning to fire, it seems the warning must be enabled at the point of occurrence and at the end of the file.
This isn't true for other warnings like -Wsign-compare
.
You can see an example here: https://godbolt.org/z/4eGc5hdzd
Initially there are no -Wunsafe-buffer-usage
warnings. But if you uncomment the last line of the input (#pragma clang diagnostic warning "-Wunsafe-buffer-usage"
) then warnings that appear earlier in the file will show up.