Skip to content

3.14.0b2 fails to build with strictly C11 compliant compiler #134875

Closed
@jmroot

Description

@jmroot

Bug report

Bug description:

With a compiler that implements atomic_load_explicit as specified in the C11 standard (such as many older versions of clang), Python 3.14.0b2 fails to build:

In file included from Parser/pegen.c:3:
In file included from ./Include/internal/pycore_pystate.h:12:
In file included from ./Include/internal/pycore_tstate.h:13:
In file included from ./Include/internal/pycore_mimalloc.h:45:
./Include/internal/mimalloc/mimalloc/internal.h:640:23: error: address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(mi_encoded_t) *' invalid)
  next = (mi_block_t*)mi_atomic_load_relaxed(&block->next);
                      ^                      ~~~~~~~~~~~~
./Include/internal/mimalloc/mimalloc/atomic.h:61:50: note: expanded from macro 'mi_atomic_load_relaxed'
#define mi_atomic_load_relaxed(p)                mi_atomic(load_explicit)(p,mi_memory_order(relaxed))
                                                 ^                        ~
./Include/internal/mimalloc/mimalloc/atomic.h:42:33: note: expanded from macro 'mi_atomic'
#define  mi_atomic(name)        atomic_##name
                                ^
<scratch space>:40:1: note: expanded from here
atomic_load_explicit
^

Using const here wasn't allowed until C17: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_459

This is a regression since b1.

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions