On Thu, 7 Sep 2017, Jakub Jelinek wrote:
> Hi!
>
> The powerpc patch I've just posted led me to try __atomic_* builtins
> on arrays as in the testcase below. While it works fine if the
> array is just on the first argument or in C, in C++ for arrays in 2nd
> or 3rd argument the atomics are rejected (complaining that the argument
> is not a pointer), while we should really have performed array-to-pointer
> conversion first.
>
> Fixed thusly, bootstrapped/regtested on powerpc64-linux, ok for trunk?
I don't think either the existing or new assertion that arrays only occur
in C++ are correct. E.g. build the following with -std=gnu90 so
non-lvalue arrays don't decay to pointers. (ICEs on such an assertion in
get_atomic_generic_size with a trunk build as of a few days ago.)
struct s { int c[10]; };
struct s f (void);
void
g (void)
{
__atomic_load ( f().c, f().c, __ATOMIC_ACQUIRE);
}
(I think C90 non-lvalue arrays there are most appropriately an error,
rather than attempting to make them decay to pointers after all.)
--
Joseph S. Myers
[email protected]