[libcxx-commits] [libcxx] [libc++][NFC] Remove unnecessary unsigned comparison with 0 (PR #108391)

Mital Ashok via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 12 06:44:27 PDT 2024


https://github.com/MitalAshok created https://github.com/llvm/llvm-project/pull/108391

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

>From d2892d9321e6fb064f0ef76c5d3d594ef498e3c2 Mon Sep 17 00:00:00 2001
From: Mital Ashok <mital at mitalashok.co.uk>
Date: Thu, 12 Sep 2024 14:30:24 +0100
Subject: [PATCH] [libc++][NFC] Remove unnecessary unsigned comparison with 0

This fixes a -Wtype-limit warning emitted when this file is compiled with GCC when assertions are enabled.
---
 libcxx/include/experimental/__simd/vec_ext.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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;
   }
 };



More information about the libcxx-commits mailing list