Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[libc] Fix implicit conversion error on rv32 #138622

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

mikhailramalho
Copy link
Member

This patch fixes the following error on rv32 (and possibly other 32-bit archs):

FPBits.h:760:40: error: implicit conversion loses integer precision: 'int' to 'size_t' (aka 'unsigned int') [-Werror,-Wimplicit-int-conversion]
760 | result.set_significand(number >> -ep);

Fixes #138425.

This patch fixes the following error on rv32 (and possibly other 32-bit
archs):

FPBits.h:760:40: error: implicit conversion loses integer precision: 'int' to 'size_t' (aka 'unsigned int') [-Werror,-Wimplicit-int-conversion]
  760 |       result.set_significand(number >> -ep);

Fixes llvm#138425.
@llvmbot
Copy link
Member

llvmbot commented May 6, 2025

@llvm/pr-subscribers-libc

Author: Mikhail R. Gadelha (mikhailramalho)

Changes

This patch fixes the following error on rv32 (and possibly other 32-bit archs):

FPBits.h:760:40: error: implicit conversion loses integer precision: 'int' to 'size_t' (aka 'unsigned int') [-Werror,-Wimplicit-int-conversion]
760 | result.set_significand(number >> -ep);

Fixes #138425.


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

1 Files Affected:

  • (modified) libc/src/__support/FPUtil/FPBits.h (+1-1)
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index bee8d0a8dc47d..4fa3bc30ecd12 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -757,7 +757,7 @@ struct FPRepImpl : public FPRepSem<fp_type, RetT> {
       result.set_significand(number);
       result.set_biased_exponent(static_cast<StorageType>(ep + 1));
     } else {
-      result.set_significand(number >> -ep);
+      result.set_significand(number >> static_cast<unsigned>(-ep));
     }
     return RetT(result.uintval());
   }

@mikhailramalho mikhailramalho merged commit 2dd296a into llvm:main May 6, 2025
18 checks passed
@mikhailramalho mikhailramalho deleted the rv32-fix-implicit branch May 6, 2025 14:31
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
This patch fixes the following error on rv32 (and possibly other 32-bit
archs):

FPBits.h:760:40: error: implicit conversion loses integer precision:
'int' to 'size_t' (aka 'unsigned int')
[-Werror,-Wimplicit-int-conversion]
  760 |       result.set_significand(number >> -ep);

Fixes llvm#138425.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] implicit conversion error on rv32
3 participants