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

[libc++][NFC] Remove unnecessary unsigned comparison with 0 #108391

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

MitalAshok
Copy link
Contributor

This fixes a -Wtype-limits warning emitted when this file is compiled with GCC when assertions are enabled.

This fixes a -Wtype-limit warning emitted when this file is compiled with GCC when assertions are enabled.
@MitalAshok MitalAshok requested a review from a team as a code owner September 12, 2024 13:44
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 12, 2024

@llvm/pr-subscribers-libcxx

Author: Mital Ashok (MitalAshok)

Changes

This fixes a -Wtype-limits warning emitted when this file is compiled with GCC when assertions are enabled.


Full diff: https://github.com/llvm/llvm-project/pull/108391.diff

1 Files Affected:

  • (modified) libcxx/include/experimental/__simd/vec_ext.h (+2-2)
diff --git a/libcxx/include/experimental/__simd/vec_ext.h b/libcxx/include/experimental/__simd/vec_ext.h
index 1f707cf3e18424..6c7fb8b09a467c 100644
--- a/libcxx/include/experimental/__simd/vec_ext.h
+++ b/libcxx/include/experimental/__simd/vec_ext.h
@@ -40,11 +40,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {
   _Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));
 
   _LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {
-    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
+    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds");
     return __data[__idx];
   }
   _LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept {
-    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
+    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds");
     __data[__idx] = __v;
   }
 };

@MitalAshok
Copy link
Contributor Author

Split off from #107713
Note that this is an existing issue even without trying to change _LIBCPP_ASSUME: https://godbolt.org/z/65Gnn639e
No test runner seems to run a combination of gcc-14 + assertions that compiles with this file that would have caught this

@ldionne ldionne merged commit c34aca8 into llvm:main Sep 13, 2024
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants