Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top-level code not analyzed by -Wunsafe-buffer-usage #92664

Open
pkasting opened this issue May 18, 2024 · 0 comments
Open

Top-level code not analyzed by -Wunsafe-buffer-usage #92664

pkasting opened this issue May 18, 2024 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative

Comments

@pkasting
Copy link
Member

In issue 92191 we discovered -Wunsafe-buffer-usage is apparently not run on top-level code. The following snippet demonstrates this.

int i = 0;
int* j = &i;
int* k1 = j - 1;  // No warning (bug)

void foo() {
  int* k2 = j - 1;  // Warning
}

Live repro: https://godbolt.org/z/x58vKoqje
@haoNoQ @jkorous-apple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative
Projects
None yet
Development

No branches or pull requests

2 participants