[llvm-bugs] [Bug 49398] New: clang rejects valid code that uses _Atomic

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 2 07:23:20 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49398

            Bug ID: 49398
           Summary: clang rejects valid code that uses _Atomic
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alastair.donaldson at imperial.ac.uk
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 24582
  --> https://bugs.llvm.org/attachment.cgi?id=24582&action=edit
Valid C program that clang rejects

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

clang -std=c17 -c ex.c

LLVM revision from which clang was built:
493f1407927cdf6db2e08f150ed9f9b8abe4ac45

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210302/0612f9e7/attachment.html>


More information about the llvm-bugs mailing list