Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2022 05:06:10 +0000
From:      bugzilla-noreply@freebsd.org
To:        toolchain@FreeBSD.org
Subject:   [Bug 265181] Clang doesn't properly report the C++ error when float is used as an argument in bit-wise operators (only on armv6 some error is reported instead of reporting it on all architectures)
Message-ID:  <bug-265181-29464-hcUD2hte3A@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-265181-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-265181-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265181

--- Comment #6 from Mark Millard <marklmi26-fbsd@yahoo.com> ---
(In reply to Yuri Victorovich from comment #4)

clang is not what supplied bswap_32 :

/usr/include/infiniband/byteswap.h

provides:

#define bswap_32        bswap32

(I switch to /usr/src/ style paths starting here.)

/usr/13_0R-src/sys/sys/endian.h

provides:

#define bswap32(x)      __bswap32(x)

You are welcome to go explore the range
architecture specific definitions in:

(The space then tab sequence in the []'s below likely will not make
it through the copy/paste sequence.)

# grep -r "define[     ]*\<__bswap32\>" /usr/13_0R-src/sys/ | more
/usr/13_0R-src/sys/arm64/include/endian.h:#define       __bswap32(x)    \
/usr/13_0R-src/sys/arm64/include/endian.h:#define       __bswap32(x)=20=20=
=20
__bswap32_var(x)
/usr/13_0R-src/sys/arm/include/endian.h:#define __bswap32(x)    \
/usr/13_0R-src/sys/arm/include/endian.h:#define __bswap32(x)=20=20=20
__bswap32_var(x)
/usr/13_0R-src/sys/x86/include/endian.h:#define __bswap32(x)=20=20=20
__builtin_bswap32(x)
/usr/13_0R-src/sys/riscv/include/endian.h:#define       __bswap32(x)    \
/usr/13_0R-src/sys/riscv/include/endian.h:#define       __bswap32(x)=20=20=
=20
__bswap32_var(x)
/usr/13_0R-src/sys/mips/include/endian.h:#define        __bswap32(x)=20=20=
=20
((__uint32_t)(__is_constant((x)) ?              \
/usr/13_0R-src/sys/powerpc/include/endian.h:#define     __bswap32(x)=20=20=
=20
(__is_constant(x) ? __bswap32_const(x) : \

But even with just that much of a grep, note the x86 using:

__builtin_bswap32(x)

which is not going to have any binary operators involved at all.
Such is not clang's problem for why that is different.

I'll note that FreeBSD's arm/include/endian.h definitions
are far from uniform for type handling:

static __inline __uint32_t
__bswap32_var(__uint32_t v)
{
        __uint32_t t1;

        __asm __volatile("eor %1, %0, %0, ror #16\n"
                        "bic %1, %1, #0x00ff0000\n"
                        "mov %0, %0, ror #8\n"
                        "eor %0, %0, %1, lsr #8\n"
                         : "+r" (v), "=3Dr" (t1));

        return (v);
}
. . .
#ifdef __OPTIMIZE__

#define __bswap32_constant(x)   \
    ((((x) & 0xff000000U) >> 24) |      \
     (((x) & 0x00ff0000U) >>  8) |      \
     (((x) & 0x0000ff00U) <<  8) |      \
     (((x) & 0x000000ffU) << 24))
. . .
#define __bswap32(x)    \
    ((__uint32_t)(__builtin_constant_p(x) ?     \
     __bswap32_constant(x) :                    \
     __bswap32_var(x)))

#else
#define __bswap16(x)    __bswap16_var(x)
#define __bswap32(x)    __bswap32_var(x)

#endif /* __OPTIMIZE__ */


__bswap32_var will not produce such binary operator
related messages. But, for __OPTIMIZE__, __bswap32_constant
usage will. So the __bswap32(x) usage will vary based
on constant expressions vs. non-constant expressions.

Again: Not clang++'s problem since it is not clang's set of
definitions. clang++ is doing what it is told to by the
language standard and code it was supplied.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-265181-29464-hcUD2hte3A>