Skip to content

[libc][stdbit] Typos in type generic macros for bit_width, bit_floor #84658

@ashfordium

Description

@ashfordium

I think I noticed a potential typo in the stdbit type generic macros for stdc_bit_width and stdc_bit_floor:

#define stdc_bit_width(x)                                                      \
  _Generic((x),                                                                \
      unsigned char: stdc_bit_width_ui, <---                                   \
      unsigned short: stdc_bit_width_us,                                       \
      unsigned: stdc_bit_width_ui,                                             \
      unsigned long: stdc_bit_width_ul,                                        \
      unsigned long long: stdc_bit_width_ull)(x)
#define stdc_bit_floor(x)                                                      \
  _Generic((x),                                                                \
      unsigned char: stdc_bit_floor_ui, <---                                   \
      unsigned short: stdc_bit_floor_us,                                       \
      unsigned: stdc_bit_floor_ui,                                             \
      unsigned long: stdc_bit_floor_ul,                                        \
      unsigned long long: stdc_bit_floor_ull)(x)

I think the assignment exprs for the assocs for unsigned char should refer to the respective *_uc functions.

Seems like this is missed by the tests because we only test the __cplusplus part of the preprocessor conditional.

I will fix these and add tests for both branches of the preprocessor conditional in stdbit-macros.h, let me know if these are actually as expected.

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