[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#984057: infinipath-psm: ftbfs with GCC-11



tags 984057 + patch
user debian-release@lists.debian.org
usertags 984057 + bsp-2022-10-de-karlsruhe
thank you

Matthias Klose wrote...

> /<<PKGBUILDDIR>>/include/linux-x86_64/sysdep.h:109:5: error: array subscript ‘struct xchg_dummy[0]’ is partly outside array bounds of ‘psmi_spinlock_t[1]’ {aka ‘ips_atomic_t[1]’} [-Werror=array-bounds]
>   109 |     asm volatile(LOCK_PREFIX "cmpxchgl %1,%2"
>       |     ^~~

After staring at this for a while I think upstream did some creepy
things gcc is understandably happy, but overall this code in sysdep.h

| static __inline__ uint32_t ips_cmpxchg(volatile uint32_t *ptr,
| 				       uint32_t old, uint32_t new)
| {
|     uint32_t prev;
|     struct xchg_dummy { uint32_t a[100]; };
| 
|     asm volatile(LOCK_PREFIX "cmpxchgl %1,%2"
| 		 : "=a"(prev)
| 		 : "q"(new), "m"(*(struct xchg_dummy *)ptr), "0"(old)
| 		 : "memory");
| 
|     return prev;
| }

is okay-ish. And so, unless someone finds a saner way (I guess it's
replacing the 100 with a better value, possibly architecture-dependent),
I'd just disable the warning, patch attached, makes the build pass.

    Christoph
--- a/include/linux-i386/sysdep.h
+++ b/include/linux-i386/sysdep.h
@@ -106,10 +106,13 @@
     uint32_t prev;
     struct xchg_dummy { uint32_t a[100]; };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
     asm volatile(LOCK_PREFIX "cmpxchgl %1,%2"
 		 : "=a"(prev)
 		 : "q"(new), "m"(*(struct xchg_dummy *)ptr), "0"(old)
 		 : "memory");
+#pragma GCC diagnostic pop
 
     return prev;
 }

Attachment: signature.asc
Description: PGP signature


Reply to: