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

-Warray-bounds false positive when a cast is involved #11143

Closed
seanm opened this issue Aug 26, 2011 · 7 comments
Closed

-Warray-bounds false positive when a cast is involved #11143

seanm opened this issue Aug 26, 2011 · 7 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@seanm
Copy link

seanm commented Aug 26, 2011

Bugzilla Link 10771
Resolution FIXED
Resolved on Sep 22, 2011 09:50
Version trunk
OS All
CC @DougGregor,@belkadan,@tkremenek,@nico

Extended Description

Consider this C++:

int main (void)
{
double foo[4096];
((char *)(foo))[(sizeof(foo)-1)] = '\0';

return 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).

@efriedma-quic
Copy link
Collaborator

*** Bug llvm/llvm-bugzilla-archive#10937 has been marked as a duplicate of this bug. ***

@nico
Copy link
Contributor

nico commented Sep 16, 2011

This happens e.g. in ICU

@seanm
Copy link
Author

seanm commented Sep 16, 2011

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

@nico
Copy link
Contributor

nico commented Sep 18, 2011

r139990

@seanm
Copy link
Author

seanm commented Sep 22, 2011

Confirmed fixed.

@efriedma-quic
Copy link
Collaborator

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

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 27, 2021

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

4 participants