[llvm-bugs] [Bug 47866] New: asm() can't dereference pointer to incomplete type 'const char []'

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 15 14:11:08 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47866

            Bug ID: 47866
           Summary: asm() can't dereference pointer to incomplete type
                    'const char []'
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: blubban at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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: https://godbolt.org/z/ejGWK9

(Yes, it's buggy for inputs longer than 4GB. Maybe it's i386 only. But that's
not a Clang or LLVM bug.)

[1]
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#index-asm-scratch-registers

-- 
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/20201015/e92e5116/attachment.html>


More information about the llvm-bugs mailing list