Skip to contentSkip to conversation

fix build with clang

PATCH Superseded Norbert Lange 3 participants 3 messages Jul 21, 2022 – Jul 25, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix build with clang

clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.

---
 testsuite/smokey/memcheck/memcheck.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
testsuite/smokey/memcheck/memcheck.c +1 -3
index a33700f49..c12d658a4 100644
@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)
 
 static void random_shuffle(void *vbase, size_t nmemb, const size_t size)
 {
-	struct {
-		char x[size];
-	} __attribute__((packed)) *base = vbase;
+	char *base = (char *)vbase;
 	unsigned int j, k;
 	double u;
 
Signature · 1 line
2.35.1
#1 lore raw
Quoted 13 lines · Norbert Lange

clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.

---
 testsuite/smokey/memcheck/memcheck.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
testsuite/smokey/memcheck/memcheck.c +0 -0
index a33700f49..c12d658a4 100644

testsuite/smokey/memcheck/memcheck.c static inline void swap(void *left, void *right, const size_t size) · line 83

Quoted 7 lines
testsuite/smokey/memcheck/memcheck.c +1 -3
@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right, const size_t size)
 
 static void random_shuffle(void *vbase, size_t nmemb, const size_t size)
 {
-	struct {
-		char x[size];
-	} __attribute__((packed)) *base = vbase;
+	char *base = (char *)vbase;

I don't think that is the same. base[n] will address the n-th (minus one) buffer of the size 'size'.

testsuite/smokey/memcheck/memcheck.c static inline void swap(void *left, void *right, const size_t size) · line 86

Quoted 3 lines
testsuite/smokey/memcheck/memcheck.c +0 -0
 	unsigned int j, k;
 	double u;
 

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#2 lore raw
Quoted 31 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Samstag, 23. Juli 2022 16:29
To: Norbert Lange <[email protected]>; [email protected]
Cc: Lange Norbert <[email protected]>
Subject: Re: [PATCH] fix build with clang

CAUTION: External email. Do not click on links or open attachments unless you know the sender and that the content is safe.

Quoted 16 lines · Norbert Lange

clang will never support 'variable length array in structure', and there does not seem to be a reason for this weird construct.

---
 testsuite/smokey/memcheck/memcheck.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
testsuite/smokey/memcheck/memcheck.c +0 -0
index a33700f49..c12d658a4 100644
@@ -80,9 +80,7 @@ static inline void swap(void *left, void *right,
 const size_t size)
 
Quoted 13 lines

testsuite/smokey/memcheck/memcheck.c static inline void swap(void *left, void *right, const size_t size) · line 83

Quoted 6 lines
testsuite/smokey/memcheck/memcheck.c +1 -3
 static void random_shuffle(void *vbase, size_t nmemb, const size_t
 size)  {
-     struct {
-             char x[size];
-     } __attribute__((packed)) *base = vbase;
+     char *base = (char *)vbase;

I don't think that is the same. base[n] will address the n-th (minus one) buffer of the size 'size'.

Quoted 3 lines
testsuite/smokey/memcheck/memcheck.c +0 -0
      unsigned int j, k;
      double u;

True, v2 generates the same code now: https://godbolt.org/z/1KhaM79qr

Norbert
________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH

Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
________________________________