Commit cb77f42
keyboard_report_util: cast keys to uint8_t in the brace-init list
Apple clang 21 fails the test build with:
tests/test_common/keyboard_report_util.hpp:38:81: error:
non-constant-expression cannot be narrowed from type
'qk_keycode_defines' to 'value_type' (aka 'unsigned char') in
initializer list [-Wc++11-narrowing]
38 | return testing::MakeMatcher(new KeyboardReportMatcher(
std::vector<uint8_t>({keys...})));
Callers like EXPECT_REPORT(driver, (KC_SPACE)) deduce the variadic
pack as qk_keycode_defines, and std::vector<uint8_t>{keys...} is a
brace-init list -- the one context where C++11 narrowing rules apply.
clang's -Wc++11-narrowing rejects the implicit enum -> uint8_t
conversion there; gcc was lenient, which is why Linux CI didn't catch
this.
The narrowing is purely type-based: every real call site passes
basic keycodes that fit in a byte by construction (action-layer
processing has already reduced any wider keycodes upstream of the
report builder), but the enum type itself is wider than uint8_t and
that's what the rule keys off of. Make the conversion explicit with
a static_cast in the pack expansion so the brace-init list sees a
uint8_t to begin with and the narrowing rule has nothing to fire on.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ce6c923 commit cb77f42
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
0 commit comments