<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - asm() can't dereference pointer to incomplete type 'const char []'"
href="https://bugs.llvm.org/show_bug.cgi?id=47866">47866</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>asm() can't dereference pointer to incomplete type 'const char []'
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>blubban@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>One of the examples from the GCC manual [1] fails to compile.
unsigned my_strlen(const char * p)
{
unsigned count;
asm("repne scasb"
: "=c" (count), "+D" (p)
: "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
return ~count - 1;
}
GCC does, of course, compile its examples correctly, but Clang is less happy
about dereferencing a pointer to incomplete type 'const char []'. I agree
manipulating incomplete types generally doesn't make sense, but in this
particular case, being able to represent arrays of unknown bounds is useful.
Online reproducer: <a href="https://godbolt.org/z/ejGWK9">https://godbolt.org/z/ejGWK9</a>
(Yes, it's buggy for inputs longer than 4GB. Maybe it's i386 only. But that's
not a Clang or LLVM bug.)
[1]
<a href="https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#index-asm-scratch-registers">https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#index-asm-scratch-registers</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>