On 1/6/19 11:38 AM, Eric Blake wrote:
> +/*
> + * Automatic type deduction, to be used as:
> + * QEMU_TYPEOF(expr) name = expr;
> + */
> +#if QEMU_GNUC_PREREQ(4, 9)
> +# define QEMU_TYPEOF(a) __auto_type
> +#else
> +# define QEMU_TYPEOF(a) typeof(a)
> +#endif

What's wrong with always using typeof?  This seems like it leaves potential odd
bugs affecting gcc-4.8.

> +#undef MIN
> +#define MIN(a, b)                            \
> +    ({                                       \
> +        QEMU_TYPEOF((a) + 0) _a = (a) + 0;   \
> +        QEMU_TYPEOF((b) + 0) _b = (b) + 0;   \

If you're promoting the type, why don't you want to promote to the common type
between A and B?  E.g.

  __typeof((a) + (b)) _a = (a), _b = (b);

After all, that's what the result type of (p ? _a : _b) will be.


r~

Reply via email to