Skip to content

__c11_atomic_add_fetch is not implemented #133697

@pakluba

Description

@pakluba

Could you please implement the missing C11 variants of the atomic builtins?

I was using stdatomic.h in my code, sometimes directly with the __atomic_* builtins, but got a quite confusing compilation error:

address argument to atomic operation must be a pointer to integer, pointer or supported floating point type ('atomic_uint *' (aka '_Atomic(unsigned int) *') invalid

After doing some search it turned out that instead of the __atomic_* builtins the __c11_atomic_* builtins shall be used. It fixed most of my issues except where a __c11_* variant is not available.

While those are not available, it it OK to make the compilation error go away by casting the atomic pointer to ordinary pointer?

__atomic_add_fetch((unsigned int *)(ptr), val, memorder)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing featureextension:clangwontfixIssue is real, but we can't or won't fix it. Not invalid
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions