[llvm-bugs] [Bug 40769] New: stdatomic.h not C11 compliant with Objective C framework

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 18 20:12:20 PST 2019


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

            Bug ID: 40769
           Summary: stdatomic.h not C11 compliant with Objective C
                    framework
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
          Assignee: unassignedclangbugs at nondot.org
          Reporter: theboywonder2244 at yahoo.co.jp
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

On Mac OSX 10.4 (Mojave) with Apple LLVM Version 10.0.0 (clang-1000.11.45.5)

I have written my own <stdatomic.h> for multiple platforms that don't support
it. It is designed to work under all C11-compliant compilers. My own
<stdatomic.h> has a gate that says:

#ifndef __STDC_NO_ATOMICS__
#  error ... error text goes here ...
#endif

As my entire source repository is a shared repository, this file is visible
during compilation on all platforms. I use "-idirafter" to make sure that any 
file provided by the hosted environment gets picked up before my file.

If clang on Mac OSX is invoked on a file with ".c" extension then the hosted
environment doesn't supply <stdatomic.h>. In this case __STDC_NO_ATOMICS__ is
defined, my custom file is called, and it compiles cleanly.

However, for the Objective C framework, LLVM headers provide a <stdatomic.h>.
Inside this file is the following:

#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
#  include_next <statomic.h>
#endif

The extension "include_next" searches "-idirafter" and sees my <stdatomic.h>
and includes it, but it does *not* define __STDC_NO_ATOMICS__ so the gate
within my custom <stdatomic.h> is entered and the build always fails. This
appears to be a violation of C2011.

-- 
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/20190219/50eb5c8a/attachment.html>


More information about the llvm-bugs mailing list