clang rejects valid code that uses _Atomic · Issue #48742 · llvm/llvm-project (original) (raw)

Bugzilla Link 49398
Version trunk
OS Linux
Attachments Valid C program that clang rejects
CC @DougGregor,@zygoloid

Extended Description

Command (where ex.c is the attached file):

clang -std=c17 -c ex.c

LLVM revision from which clang was built: 493f140

Expected behaviour: the program should compile successfully.

Actual behaviour: clang gives this error:

ex.c:3:7: error: initializing 'int' with an expression of incompatible type '_Atomic(int)'

The program is successfully compiled by gcc 9.3.0.

The program in the attached file is:

void foo() {
_Atomic int x;
int y = (x = 2);
}

which I believe is valid: it's fine to initialize a non-atomic int using an atomic int.

If the declaration of y is changed to:

int y = x;

then the program compiles successfully.