-
Notifications
You must be signed in to change notification settings - Fork 70
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
core: address error=array-bounds in gcc14 #2639
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you think this is a false positive warning?
return std::nullopt; | ||
} | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Warray-bounds" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed given the if-check above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed given the if-check above?
The error is still emitted unfortunately even with the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you clarify the error? how does a big number like "576460752303423485" or "9223372036854775760" end up there despite the check? who is passing that number? could it be that if
is faulty due to some signed-unsigned UB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know where this number comes from (it's some internal details of the array-bounds check in gcc). The comparison is fine (both arguments are of type size_t
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning comes from optimized GCC builds. After some optimizations related to inlining and constant propagation compiler can convince itself that it knows the access index of an array and compare it with the array size.
Unfortunately, this analysis is known to have false-positives, see e.g.
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100038
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699
If we want to be nice and you think it is worth the time I can reduce this example and report an issue. Or I can make a tutorial how to reduce failing compilations.
Yes, I think so |
Address the following error when compling with gcc 14.2: