fix build with clang
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
@@ -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
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.
Signed-off-by Norbert Lange <[email protected]>--- testsuite/smokey/memcheck/memcheck.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)testsuite/smokey/memcheck/memcheck.c +0
-0
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
-0unsigned int j, k;double u;
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
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 clangCAUTION: 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.
Signed-off-by Norbert Lange <[email protected]>--- testsuite/smokey/memcheck/memcheck.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)testsuite/smokey/memcheck/memcheck.c +0
-0@@ -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
-3static 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
-0unsigned 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
________________________________