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

clang-diagnostic-array-bounds warning for impossible case in switch statement #35463

Open
nickdesaulniers opened this issue Jan 26, 2018 · 3 comments
Labels
bugzilla Issues migrated from bugzilla clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang Clang issues not falling into any other category

Comments

@nickdesaulniers
Copy link
Member

Bugzilla Link 36115
Version unspecified
OS Linux
CC @EugeneZelenko

Extended Description

STR:

void w () {
  int y [10];
  switch (10) {
    case 300:
      y[300] = 4;
    default:
      //break;
  }
}

clang-tidy -warnings-as-errors=clang-diagnostic-array-bounds test_case.c

/tmp/test_case.c:6:7: error: array index 300 is past the end of the array (which contains 10 elements) [clang-diagnostic-array-bounds,-warnings-as-errors]
y[300] = 4;
^
/tmp/test_case.c:3:3: note: array 'y' declared here
int y [10];
^

My test case is definitely contrived, but I see effectively the same thing running clang-tidy on the Linux kernel in include/linux/signal.h:122

@EugeneZelenko
Copy link
Contributor

clang-diagnostic group is alias for Clang warnings. Could you please verify that Clang produces same warning? In such cases report should be changed to Clang.

@nickdesaulniers
Copy link
Member Author

Clang also produces the same warning.

@nathanchance
Copy link
Member

mentioned in issue llvm/llvm-bugzilla-archive#51682

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@xgupta xgupta added the clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

4 participants