[LLVMbugs] [Bug 24108] New: clang c11 atomics are non-conforming
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jul 13 11:45:11 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24108
Bug ID: 24108
Summary: clang c11 atomics are non-conforming
Product: clang
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: stefan.teleman at oracle.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 14584
--> https://llvm.org/bugs/attachment.cgi?id=14584&action=edit
c11 atomics test program
The following test program:
/* at.c */
#include <stdio.h>
#include <stdlib.h>
#include <stdatomic.h>
struct Test {
int i;
_Atomic int ai;
double d;
_Atomic double ad;
};
int main()
{
struct Test T;
_Atomic struct Test AT;
_Atomic struct Test *TP = ATOMIC_VAR_INIT(NULL);
T.i = 1;
AT.i = 0;
T.ai = ATOMIC_VAR_INIT(1);
AT.ai = ATOMIC_VAR_INIT(0);
T.d = 2.5;
AT.d = 1.5;
T.ad = ATOMIC_VAR_INIT(2.5);
AT.ad = ATOMIC_VAR_INIT(1.5);
(void) fprintf(stdout, "T.i=%i, T.ai=%i, T.d=%lf, T.ad=%lf\n",
T.i, T.ai, T.d, T.ad);
(void) fprintf(stdout, "AT.i=%i, AT.ai=%i, AT.d=%lf, AT.ad=%lf\n",
AT.i, AT.ai, AT.d, AT.ad);
atomic_store(&AT, T);
(void) fprintf(stdout, "T.i=%i, T.ai=%i, T.d=%lf, T.ad=%lf\n",
T.i, T.ai, T.d, T.ad);
(void) fprintf(stdout, "AT.i=%i, AT.ai=%i, AT.d=%lf, AT.ad=%lf\n",
AT.i, AT.ai, AT.d, AT.ad);
return 0;
}
----------------------------------------------------------------------------
When compiled on Fedora 21 x86_64 with clang 3.6.1, using the official
Fedora binaries from llvm.org:
/usr/local/clang-361/bin/clang --version
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
--------------------------------------------------------------------------
/usr/local/clang-361/bin/clang -m64 -O0 -std=c11 -Wall -emit-llvm -S at.c -o
at.ll
--------------------------------------------------------------------------
at.c:19:5: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i = 0;
~~^~
at.c:21:5: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.ai = ATOMIC_VAR_INIT(0);
~~^~~
at.c:23:5: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.d = 1.5;
~~^~
at.c:25:5: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.ad = ATOMIC_VAR_INIT(1.5);
~~^~~
at.c:30:20: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~
at.c:30:26: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~~
at.c:30:33: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~
at.c:30:39: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~~
at.c:37:20: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~
at.c:37:26: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~~
at.c:37:33: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~
at.c:37:39: error: member reference base type '_Atomic(struct Test)' is not a
structure or union
AT.i, AT.ai, AT.d, AT.ad);
~~^~~
12 errors generated.
--------------------------------------------------------------------------
When compiled with GCC 4.9.2 in Fedora 21:
/usr/bin/gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
---------------------------------------------------------------------------
/usr/bin/gcc -m64 -O0 -std=c11 -Wall -c at.c -o at.o
---------------------------------------------------------------------------
at.c: In function 'main':
at.c:16:24: warning: unused variable 'TP' [-Wunused-variable]
_Atomic struct Test *TP = ATOMIC_VAR_INIT(NULL);
---------------------------------------------------------------------------
--
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/20150713/7afe8a83/attachment.html>
More information about the llvm-bugs
mailing list