Skip to content

Commit 6eb8478

Browse files
scottlambclaude
andcommitted
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 b0f4224 commit 6eb8478

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tests/test_common/keyboard_report_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ class KeyboardReportMatcher : public testing::MatcherInterface<report_keyboard_t
3535

3636
template <typename... Ts>
3737
inline testing::Matcher<report_keyboard_t&> KeyboardReport(Ts... keys) {
38-
return testing::MakeMatcher(new KeyboardReportMatcher(std::vector<uint8_t>({keys...})));
38+
return testing::MakeMatcher(new KeyboardReportMatcher({static_cast<uint8_t>(keys)...}));
3939
}

0 commit comments

Comments
 (0)