Skip to content

clang rejects valid code that uses _Atomic #48742

@afd

Description

@afd
mannequin
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.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac11clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyrejects-valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions