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
-Warray-bounds false positive when a cast is involved #11143
Comments
*** Bug llvm/llvm-bugzilla-archive#10937 has been marked as a duplicate of this bug. *** |
This happens e.g. in ICU |
In my case, the original code in question is from the open source ITK project. The warning can be seen on its nightly dashboard: http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=1533029 |
r139990 |
Confirmed fixed. |
mentioned in issue llvm/llvm-bugzilla-archive#10937 |
mentioned in issue llvm/llvm-bugzilla-archive#44343 |
Extended Description
Consider this C++:
int main (void)
{
double foo[4096];
((char *)(foo))[(sizeof(foo)-1)] = '\0';
}
It outputs:
test.cp:4:12: warning: array index of '32767' indexes past the end of an array (that contains 4096 elements) [-Warray-bounds]
((char *)(foo))[(sizeof(foo)-1)] = '\0';
^ ~~~~~~~~~~~~~
It's a false positive. Note the cast to char*.
This is with clang version 3.0 (trunk 138577).
The text was updated successfully, but these errors were encountered: