On Mon, Oct 19, 2020 at 12:59:01AM +0100, Ramsay Jones wrote: > On 17/10/2020 23:56, Luc Van Oostenryck wrote: > > diff --git a/builtin.c b/builtin.c > > index 880dd54f647e..5e490830e147 100644 > > --- a/builtin.c > > +++ b/builtin.c > > @@ -627,23 +627,23 @@ static const struct builtin_fn builtins_common[] = { > > { "__builtin___vsnprintf_chk", &int_ctype, 0, { &string_ctype, size_t_ctype, &int_ctype, size_t_ctype, &const_string_ctype, va_list_ctype }}, > > { "__builtin___vsprintf_chk", &int_ctype, 0, { &string_ctype, &int_ctype, size_t_ctype, &const_string_ctype, va_list_ctype }}, > > > > - { "__sync_add_and_fetch", &int_ctype, 1, { &ptr_ctype }}, > > - { "__sync_and_and_fetch", &int_ctype, 1, { &ptr_ctype }}, > > + { "__sync_add_and_fetch", NULL, 1, { vol_ptr, &dyntype }, .op = &atomic_op }, > > + { "__sync_and_and_fetch", NULL, 1, { vol_ptr, &dyntype }, .op = &atomic_op }, > > Hmm, I get that the return type is derived from the type of the first > argument, but I don't see where that return type is checked/assigned > to the function return type. :( So, why are these set to NULL, but ... > > > { "__sync_bool_compare_and_swap", &bool_ctype, 1, { vol_ptr, &dyntype, &dyntype }, .op = &atomic_op}, > > ... this one isn't? Well, yes, __sync_bool_compare_and_swap() is defined as returning a bool, so it can directly specified here. For the other functions, for example __sync_add_and_fetch(), the return type must indeed be deduced form the type of the first argument. It is set at the end of eval_atomic_common() if (!expr->ctype) // __sync_val_compare_and_swap() expr->ctype = ctype; The comment should be removed or replaced by a real one. I'll clarify that. Thanks for noticng this. -- Luc