<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - clang c11 atomics are non-conforming" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24108&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=d8DEj-fjuyOshb2zw5WtKEfrGX6_-wgLLJS_yy1ZcCw&s=jb2VwFeJf5kUMFSTjl1MN7pZZPGf0oJg09FbGOhFtGY&e=">24108</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang c11 atomics are non-conforming
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stefan.teleman@oracle.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14584" name="attach_14584" title="c11 atomics test program">attachment 14584</a> <a href="attachment.cgi?id=14584&action=edit" title="c11 atomics test program">[details]</a></span>
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);

---------------------------------------------------------------------------</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>