[LLVMbugs] [Bug 9041] New: __sync* macros not equivalent to GCC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 24 14:21:16 PST 2011


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

           Summary: __sync* macros not equivalent to GCC
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: manuel.holtgrewe at fu-berlin.de
                CC: llvmbugs at cs.uiuc.edu


Hi, the following simple test program generates the errors below while gcc
compiles the program.

--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--

template <typename T>
void test()
{
  T volatile x = 0;
  T y = 0;
  T z = 0;
  __sync_fetch_and_add(&x, y, z);
  __sync_fetch_and_or(&x, y, z);
  __sync_fetch_and_xor(&x, y, z);
  __sync_val_compare_and_swap(&x, y, z);
}

int main()
{
  test<char>();
  test<unsigned char>();
  test<int>();
  test<unsigned int>();
  test<short>();
  test<unsigned short>();
  test<long>();
  test<unsigned long>();
  test<long long>();
  test<unsigned long long>();
  return 0;
}

--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--

$ g++-4.3 --version
g++-4.3 (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 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.

$ g++-4.3 main.cpp
$ clang++-trunk --version
clang version 2.9 (trunk 122567)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang++-trunk -ferror-limit=1000 main.cpp
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned char volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:16:3: note: in instantiation of function template specialization
'test<unsigned char>' requested here
  test<unsigned char>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned char volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned char volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned char volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'int volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:17:3: note: in instantiation of function template specialization
'test<int>' requested here
  test<int>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'int volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'int volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'int volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned int volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:18:3: note: in instantiation of function template specialization
'test<unsigned int>' requested here
  test<unsigned int>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned int volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned int volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned int volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'short volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:19:3: note: in instantiation of function template specialization
'test<short>' requested here
  test<short>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'short volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'short volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'short volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned short volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:20:3: note: in instantiation of function template specialization
'test<unsigned short>' requested here
  test<unsigned short>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned short volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned short volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned short volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:21:3: note: in instantiation of function template specialization
'test<long>' requested here
  test<long>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:22:3: note: in instantiation of function template specialization
'test<unsigned long>' requested here
  test<unsigned long>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long long volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:23:3: note: in instantiation of function template specialization
'test<long long>' requested here
  test<long long>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long long volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long long volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'long long volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
main.cpp:7:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long long volatile *'
  __sync_fetch_and_add(&x, y, z);
                       ^~
main.cpp:24:3: note: in instantiation of function template specialization
'test<unsigned long long>' requested here
  test<unsigned long long>();
  ^
main.cpp:8:23: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long long volatile *'
  __sync_fetch_and_or(&x, y, z);
                      ^~
main.cpp:9:24: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long long volatile *'
  __sync_fetch_and_xor(&x, y, z);
                       ^~
main.cpp:10:31: error: cannot initialize a parameter of type 'volatile char *'
with an rvalue of type 'unsigned long long volatile *'
  __sync_val_compare_and_swap(&x, y, z);
                              ^~
36 errors generated.

-- 
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