[LLVMbugs] [Bug 11280] New: __sync_bool_compare_and_swap build error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 31 14:36:39 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=11280

             Bug #: 11280
           Summary: __sync_bool_compare_and_swap build error
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: abiryan at ryand.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I've been keeping up with Clang/LLVM trunk - shortly after 139216 (which I am
assuming is the commit that broke it), applications using OpenSceneGraph fail
to build due to a compile error in the OpenThreads/Atomic header.  I've
stripped down that header to just the minimal portion that causes the error.

void* volatile _ptr;

bool
assign(void* ptrNew, const void* const ptrOld)
{
    return __sync_bool_compare_and_swap(&_ptr, ptrOld, ptrNew);
}


If you compile this with clang++ Atomic.cpp -o Atomic.o, you get the following
error:

Atomic.cpp:19:48: error: cannot initialize a parameter of type 'void *' with an
lvalue of type 'const void *const'
    return __sync_bool_compare_and_swap(&_ptr, ptrOld, ptrNew);
                                               ^~~~~~

This did work sometime before 139216, and works with a wide range of GCC
versions - that code hasn't been touched since 2008 in the upstream project.

Wondering if this is a Clang error or an error in OpenThreads - I would suspect
since it works with GCC and it's a GCC intrinsic, it's a Clang error.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list