[llvm-bugs] [Bug 42996] New: Inline assembly incompatibility with gcc for array parameters
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 14 07:41:52 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42996
Bug ID: 42996
Summary: Inline assembly incompatibility with gcc for array
parameters
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: unassignedclangbugs at nondot.org
Reporter: js at alien8.de
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Consider the following memcpy example that is adapted from the GCC
documentation [1]:
#include <stddef.h>
void* memcpy(void* dst, const void* src, size_t n)
{
void *orig_dst = dst;
asm ("rep movsb"
: "+S" (src), "+D" (dst), "+c" (n),
"=m" (*(char (*)[]) dst)
: "m" (*(const char (*)[]) src));
return orig_dst;
}
Array types is used to denote array parameters of unknown length. This works
fine on GCC, but results in the following error on clang:
string.c:10:17: error: dereference of pointer to incomplete type 'const char
[]'
: "m" (*(const char (*)[]) src));
The fix seems to be to cast to `(char (*)[n])` instead and this also works on
GCC. It's just unfortunate that the example from the gcc documentation is
broken on clang.
[1] See repne scasb here: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190814/b07e5308/attachment-0001.html>
More information about the llvm-bugs
mailing list