-
Notifications
You must be signed in to change notification settings - Fork 922
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
VS 2019 gives compiler warning C26451 for UT Array #198
Comments
Can you post a very short C source file that demonstrates the issue? |
Here is a snippet:
The last line triggers the warning. |
Darn, I thought that with a test case I'd be able to reproduce it in Godbolt, but it seems not. https://godbolt.org/z/x-HB64 Can you simplify that test case at all? For example, is this source file enough to trigger the warning?
EDIT: @guywyers, how about this one?
And re compiler options: well, make sure you're using whatever options you were using when you saw the warning before. On Godbolt I was trying to use |
Nope, that snippet doesn't trigger the warning. Maybe it's some compiler or preprocessor option which is causing this? |
@Quuxplusone: the second snippet triggered the warning. Small correction by the way: the warning code is the same (C26451), but the actual message mentions a sum ( |
I had the problem on some other lines of code as well, so I dug a little deeper. |
Similar to issue 195 for UT Hash:
Warning C26451 Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
It seems in this case it's the following line causing the warning:
#define _utarray_eltptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j))))
Doesn't seem to be dramatic, but would be nice to have it fixed.
The text was updated successfully, but these errors were encountered: