You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building with gcc 9.5.0 and the flag -Wuseless-cast, the following warnings are given:
include/aws/common/array_list.inl:122:39: warning: useless cast to type ‘void*’ [-Wuseless-cast]
122 | aws_secure_zero((void *)list->data, list->current_size);
aws/common/math.inl:89:47: warning: useless cast to type ‘size_t’ {aka ‘long unsigned int’} [-Wuseless-cast]
89 | return (size_t)aws_mul_u64_saturating(a, b);
aws/common/math.inl:103:50: warning: useless cast to type ‘uint64_t*’ {aka ‘long unsigned int*’} [-Wuseless-cast]
103 | return aws_mul_u64_checked(a, b, (uint64_t *)r);
aws/common/math.inl:116:47: warning: useless cast to type ‘size_t’ {aka ‘long unsigned int’} [-Wuseless-cast]
116 | return (size_t)aws_add_u64_saturating(a, b);
aws/common/math.inl:130:50: warning: useless cast to type ‘uint64_t*’ {aka ‘long unsigned int*’} [-Wuseless-cast]
130 | return aws_add_u64_checked(a, b, (uint64_t *)r);
aws/common/math.inl:140:47: warning: useless cast to type ‘size_t’ {aka ‘long unsigned int’} [-Wuseless-cast]
140 | return (size_t)aws_sub_u64_saturating(a, b);
aws/common/math.inl:150:50: warning: useless cast to type ‘uint64_t*’ {aka ‘long unsigned int*’} [-Wuseless-cast]
150 | return aws_sub_u64_checked(a, b, (uint64_t *)r);
The text was updated successfully, but these errors were encountered:
jmklix
added
bug
This issue is a bug.
p3
This is a minor priority issue
needs-review
This issue or pull request needs review from a core team member.
labels
Sep 21, 2023
**Issue:**
#973
This warning exists in GCC only (not Clang), and for C++ only (not C)
**Description of changes:**
- Add `-Wuseless-cast` warning to the "header checker"
- Remove useless casts in `array_list.inl`
- Ignore `-Wuseless-cast` warning in `math.inl`
- The tricky part is that SOME platforms (Apple and BSD variants) define `size_t` as `unsigned long` and require casting to `uint64_t` (aka `unsigned long long`). While other platforms define `size_t` as `unsigned long long` and warn about useless casts if you cast it to `uint64_t`. My first commit attempted to only do casts on those platforms, but it was more complex than simply ignoring the warning.
**Issue #:**
awslabs/aws-c-common#973
**Research:**
6 years ago, PR #5 made these constants `uint32_t` via a cast.
**Description of changes:**
Avoid `-Wuseless-cast` warnings, don't cast `size_t` to `uint32_t` on 32-bit platforms.
When building with gcc 9.5.0 and the flag
-Wuseless-cast
, the following warnings are given:The text was updated successfully, but these errors were encountered: