Skip to content

Fix -Wmaybe-uninitialized with GCC 16 in CHOOSE_IMPLEMENTATION macros#966

Merged
daxhuiberts merged 2 commits intomainfrom
dax-fix-gcc16
May 6, 2026
Merged

Fix -Wmaybe-uninitialized with GCC 16 in CHOOSE_IMPLEMENTATION macros#966
daxhuiberts merged 2 commits intomainfrom
dax-fix-gcc16

Conversation

@daxhuiberts
Copy link
Copy Markdown
Collaborator

@daxhuiberts daxhuiberts commented May 6, 2026

GCC 16 improved its uninitialized variable analysis and now warns that __ret_dist_func may be used uninitialized: the switch is exhaustive (e.g. CASES16 covers exactly 0-15 and dim % 16 can only produce 0-15), but GCC cannot prove this from the recursive macro expansion.

Add default: __builtin_unreachable() to both CHOOSE_IMPLEMENTATION and CHOOSE_SVE_IMPLEMENTATION to explicitly signal to the compiler that no other case is reachable, allowing it to conclude the variable is always initialized before use.


Note

Low Risk
Low risk: this is a compile-time hint to silence GCC 16 -Wmaybe-uninitialized warnings, with no intended runtime behavior change. The main risk is undefined behavior if the switch becomes non-exhaustive in the future and hits __builtin_unreachable().

Overview
Fixes new GCC 16 -Wmaybe-uninitialized warnings in implementation_chooser.h by making the switch statements in CHOOSE_IMPLEMENTATION and CHOOSE_SVE_IMPLEMENTATION explicitly exhaustive.

Adds default: __builtin_unreachable() so the compiler can prove __ret_dist_func is always initialized before assignment, without changing the selected implementation for valid inputs.

Reviewed by Cursor Bugbot for commit 17073f7. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 6, 2026

CLA assistant check
All committers have signed the CLA.

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 6, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.92%. Comparing base (4ca500a) to head (17073f7).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #966      +/-   ##
==========================================
+ Coverage   96.71%   96.92%   +0.21%     
==========================================
  Files         129      130       +1     
  Lines        8057     7749     -308     
==========================================
- Hits         7792     7511     -281     
+ Misses        265      238      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GCC 16 improved its uninitialized variable analysis and now warns that
`__ret_dist_func` may be used uninitialized: the switch is exhaustive
(e.g. `CASES16` covers exactly 0-15 and `dim % 16` can only produce
0-15), but GCC cannot prove this from the recursive macro expansion.

Add `default: __builtin_unreachable()` to both `CHOOSE_IMPLEMENTATION`
and `CHOOSE_SVE_IMPLEMENTATION` to explicitly signal to the compiler
that no other case is reachable, allowing it to conclude the variable
is always initialized before use.
@daxhuiberts daxhuiberts enabled auto-merge May 6, 2026 09:35
@daxhuiberts daxhuiberts added this pull request to the merge queue May 6, 2026
@daxhuiberts daxhuiberts removed this pull request from the merge queue due to a manual request May 6, 2026
@daxhuiberts daxhuiberts added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit d2563bf May 6, 2026
17 checks passed
@daxhuiberts daxhuiberts deleted the dax-fix-gcc16 branch May 6, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants