On Mon, Jun 13, 2016 at 01:25:35PM +0200, Richard Biener wrote: > The following avoids creating IL that accesses a FUNCTION_DECLs memory > directly rather than indirectly through an address based on it. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu, ok for trunk?
I think the problem is that for these generic builtins we perform no sanity checking, except for checking TYPE_SIZE_UNIT equality. But as you show in the PR, even that doesn't work, as while we check for VLAs on the first argument, we don't check for that on the second and following arguments. The question is what all should we reject. We accept: void foo (void); void bar (void); void baz (void); void test (void) { __atomic_exchange (&foo, &bar, &baz, __ATOMIC_RELAXED); } which IMHO we definitely should not, what does it mean to exchange functions? So, at least diagnose if any of the arguments is pointer to FUNCTION_TYPE/METHOD_TYPE and handle gracefully VLAs in 2nd+ argument. Should we perform some further type checking though, like e.g. complain if one pointer is pointer to integral type and another to floating, or one to struct, another to union, or do we just keep the builtins very forgiving and assume that on the C++ side the templates make sure the arguments are type compatible and for C _Atomic handling is done differently anyway? Jakub