Skip to content

Fix 32-bit build warnings with newer GCC on Ubuntu 25#14966

Open
vitahlin wants to merge 5 commits intoredis:unstablefrom
vitahlin:32bit-build
Open

Fix 32-bit build warnings with newer GCC on Ubuntu 25#14966
vitahlin wants to merge 5 commits intoredis:unstablefrom
vitahlin:32bit-build

Conversation

@vitahlin
Copy link
Copy Markdown
Contributor

@vitahlin vitahlin commented Mar 31, 2026

This PR fixes several compiler warnings triggered by the newer GCC toolchain (Ubuntu 25 default) when building Redis on 32-bit systems.

Changed

1. Define unreachable only when not provided by the toolchain

Recent GCC versions and C23 may provide unreachable as a built-in; unconditional redefinition can cause conflicts or build failures.

2. Enforce 8-byte alignment for C11 _Atomic on 32-bit builds

64-bit atomic types (long long, uint64_t, time_t) on 32-bit architectures require strict 8-byte alignment to remain truly atomic and avoid alignment warnings/faults. A new redisAtomicAlign(n) macro is introduced to apply attribute((aligned(n))) only on 32-bit platforms, while redisAtomic remains a plain _Atomic qualifier. This avoids unnecessary padding and struct layout changes for smaller types (int, uint32_t) and on 64-bit systems where the compiler already provides correct natural alignment.

3. Use uintptr_t for pointer–integer conversions in module tests

Direct pointer/integer casts are size-sensitive across 32/64-bit targets and trigger stricter portability warnings.

CI result: https://github.com/vitahlin/redis/actions/runs/23744054245/job/69283039740


Note

Medium Risk
Touches low-level portability primitives (jemalloc unreachable, C11 atomics alignment, and pointer/integer conversions), which could impact 32-bit correctness if misapplied, but the changes are small and largely mechanical.

Overview
Improves 32-bit build portability with newer GCC/C23 by avoiding conflicts with toolchain-provided unreachable (only defines jemalloc’s unreachable() if not already defined).

Adjusts the C11 atomic path to force 8-byte alignment for redisAtomic variables, and updates several test modules to cast metadata pointers and timer callback data through uintptr_t before storing in/reading from uint64_t or void*, eliminating size-related warnings.

Written by Cursor Bugbot for commit 75e2475. This will update automatically on new commits. Configure here.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 31, 2026

🤖 Augment PR Summary

Summary: Fixes new GCC warnings seen on 32-bit Redis builds (Ubuntu 25 toolchain).

Changes:

  • Avoids redefining unreachable() when the toolchain already provides it (jemalloc)
  • Adjusts C11 _Atomic declarations to force 8-byte alignment
  • Makes module test pointer/integer conversions portable by casting via uintptr_t

Technical Notes: The atomic alignment change impacts all redisAtomic uses under the C11 atomics path, not just 64-bit atomics on 32-bit targets.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/atomicvar.h Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Comment thread src/atomicvar.h Outdated
@vitahlin
Copy link
Copy Markdown
Contributor Author

vitahlin commented Apr 3, 2026

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.

1 participant