On Mon, Sep 21, 2026 at 6:17 PM Jakub Jelinek <[email protected]> wrote: > > On Mon, Sep 21, 2026 at 05:46:56PM -0400, Matt Turner wrote: > > +/* Fail to compile unless the asm output operand X has the same size as > > + TYPE. This stands in for casting the output to TYPE, which clang > > + rejects. */ > > +#define __ll_check_output(type, x) \ > > + ((void) sizeof (char [sizeof (x) == sizeof (type) ? 1 : -1])) > > Note, casts for output operands don't check just size, they check whether > the mode is the same, which is something different. There can be different > modes with the same size. E.g. DFmode or DImode or CSImode or V1DImode or > V2SImode or V4HImode or V8QImode all have the same size. > So just checking size is weaker than what it previously checked.
Right. Richard pointed this out in reply to the previous submission, and in [1] said "But same-size is a sufficient check. Sure, there is no nice error." when we discussed the value of type-checking. [1] https://gcc.gnu.org/pipermail/gcc-patches/2026-September/730381.html > I'd say if we are willing to change anything, there should be a macro > that can be used directly in the output operand and for non-clang it will > expand to the cast and for clang whatever else one wants (no checking at > all, checking the same, checking the mode). > So, have __asm ("..." : "=r" __ll_check_output (USItype, count) : ...); > where #define __ll_check_output(type, out) would expand to > ((type) out) for gcc and say (out) for clang. Yeah, that seems like a fine compromise to me.
