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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to