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

static_assert() condition cannot result in unsafe buffer access #92665

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

static_assert() condition cannot result in unsafe buffer access #92665

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-positive Warning fires when it should not

Comments

@pkasting
Copy link
Member

In issue 92191 we discovered -Wunsafe-buffer-usage warns on conditions inside static_asserts despite the fact that they are not executed at runtime and thus cannot result in an unsafe buffer access. The following snippet demonstrates this.

void foo() {
  int j[1] = {0};
  static_assert(j + 1 != nullptr);  // Erroneously warns
}

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

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not and removed new issue labels May 18, 2024
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-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

2 participants