[libc-commits] [libc] [llvm] [libc][NFC] Use user defined literals to build 128 and 256 bit constants. (PR #81746)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Wed Feb 14 09:42:36 PST 2024


================
@@ -76,7 +76,7 @@ template <typename T, int base> struct DigitBuffer {
   // Returns the digit for a particular character.
   // Returns 255 if the character is invalid.
   LIBC_INLINE static constexpr uint8_t get_digit_value(const char c) {
-    const auto to_lower = [](char c) { return c | 32; };
+    const auto to_lower = [](char c) -> uint8_t { return c | 32; };
     const auto is_digit = [](char c) { return c >= '0' && c <= '9'; };
     const auto is_alpha = [](char c) {
       return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
----------------
nickdesaulniers wrote:

Seems like this is producing an error on the gcc build bots:

```
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/integer_literals.h:85:16: error: conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Werror=conversion]
   85 |       return c - '0';
      |              ~~^~~~~
```

https://github.com/llvm/llvm-project/pull/81746


More information about the libc-commits mailing list