http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57926
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
Short answer.. I'm not a sure, but it appears to be a g++ thing.
I looks like g++ is using ARRAY_TYPE instead of POINTER_TYPE. the 4.8 branch
does the same thing, but it does seem odd to me. That means anywhere in the
compiler that uses POINTER_TYPE_P() is not going to trigger true for an array
in c++...
Going back to gcc 4.6 which only had __sync operations, the same issue exists:
<x220:/home/compilers/gcc-4_6-branch/build/gcc>cat t.cpp
long int Mutex[1];
int AcquireLogMutex(void)
{
return(__sync_fetch_and_add(Mutex, 1));
}
int main() {}
<x220:/home/compilers/gcc-4_6-branch/build/gcc>./cc1plus t.cpp
int AcquireLogMutex()
t.cpp:5:38: error: incompatible type for argument 1 of ‘__sync_fetch_and_add’
Im stunned this has never been tripped over.
I can fix it in the atomic code, but I don't know what that means to other
languages since I've never paid attention to the detailed meaning of ARRAY_TYPE
vs POINTER_TYPE. Just allowing the ARRAY_TYPE objects to pass the existing
atomic tests of POINTER_TYPE_P or POINTER_TYPE appears to generate all the
correct code and errors for atomics, so I guess thats is the way to go...?
there are only a couple of places the check is made.