Skip to content

-Wconstant-conversion in lib/base64.c #2181

Description

@nathanchance

After llvm/llvm-project@a5ef934:

lib/base64.c:58:18: error: implicit conversion from 'int' to 's8' (aka 'signed char') changes value from 131 to -125 [-Werror,-Wconstant-conversion]
   58 |         [BASE64_IMAP] = BASE64_REV_INIT('+', ',')
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:52:2: note: expanded from macro 'BASE64_REV_INIT'
   48 | #define BASE64_REV_INIT(ch_62, ch_63) { \
      |                                       ~
   49 |         [0 ... 0x1f] = -1, \
   50 |         INIT_32(0x20, ch_62, ch_63), \
   51 |         INIT_32(0x40, ch_62, ch_63), \
   52 |         INIT_32(0x60, ch_62, ch_63), \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:46:50: note: expanded from macro 'INIT_32'
   46 | #define INIT_32(v, ...) INIT_16(v, __VA_ARGS__), INIT_16((v) + 16, __VA_ARGS__)
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:45:49: note: expanded from macro 'INIT_16'
   45 | #define INIT_16(v, ...) INIT_8(v, __VA_ARGS__), INIT_8((v) + 8, __VA_ARGS__)
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
lib/base64.c:43:48: note: expanded from macro 'INIT_4'
   43 | #define INIT_4(v, ...) INIT_2(v, __VA_ARGS__), INIT_2((v) + 2, __VA_ARGS__)
      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:42:48: note: expanded from macro 'INIT_2'
   42 | #define INIT_2(v, ...) INIT_1(v, __VA_ARGS__), INIT_1((v) + 1, __VA_ARGS__)
      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:34:42: note: expanded from macro 'INIT_1'
   34 |                 : (v) >= '0' && (v) <= '9' ? (v) - '0' + 52 \
      |                                              ~~~~~~~~~~^~~~
lib/base64.c:58:18: error: implicit conversion from 'int' to 's8' (aka 'signed char') changes value from 130 to -126 [-Werror,-Wconstant-conversion]
   58 |         [BASE64_IMAP] = BASE64_REV_INIT('+', ',')
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:52:2: note: expanded from macro 'BASE64_REV_INIT'
   48 | #define BASE64_REV_INIT(ch_62, ch_63) { \
      |                                       ~
   49 |         [0 ... 0x1f] = -1, \
   50 |         INIT_32(0x20, ch_62, ch_63), \
   51 |         INIT_32(0x40, ch_62, ch_63), \
   52 |         INIT_32(0x60, ch_62, ch_63), \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:46:50: note: expanded from macro 'INIT_32'
   46 | #define INIT_32(v, ...) INIT_16(v, __VA_ARGS__), INIT_16((v) + 16, __VA_ARGS__)
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:45:49: note: expanded from macro 'INIT_16'
   45 | #define INIT_16(v, ...) INIT_8(v, __VA_ARGS__), INIT_8((v) + 8, __VA_ARGS__)
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
lib/base64.c:43:48: note: expanded from macro 'INIT_4'
   43 | #define INIT_4(v, ...) INIT_2(v, __VA_ARGS__), INIT_2((v) + 2, __VA_ARGS__)
      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:42:24: note: expanded from macro 'INIT_2'
   42 | #define INIT_2(v, ...) INIT_1(v, __VA_ARGS__), INIT_1((v) + 1, __VA_ARGS__)
      |                        ^~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:34:42: note: expanded from macro 'INIT_1'
   34 |                 : (v) >= '0' && (v) <= '9' ? (v) - '0' + 52 \
      |                                              ~~~~~~~~~~^~~~

This comes from a relatively recent Linux commit:

c4eb7ad32eab ("lib/base64: optimize base64_decode() with reverse lookup tables")

https://lore.kernel.org/202609110514.S0a0FD6a-lkp@intel.com/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions