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

            Bug ID: 48294
           Summary: Crash with __builtin_memcpy_inline when source is an
                    array
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: jasper.matts...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@metafoo.co.uk

Created attachment 24208
  --> https://bugs.llvm.org/attachment.cgi?id=24208&action=edit
Full backtrace from crash

__builtin_memcpy_inline uses custom type checking, and thus does not perform
default argument conversions. Basically, I invoked the builtin with a pointer
and an array as its arguments, expecting array-to-pointer decay to happen.
Instead, Clang crashed as codegen.

I'm not sure if default conversions should happen with __builtin_memcpy_inline,
but it probably should not crash.

Example code:

  int main() {
    char to, from[1];
    __builtin_memcpy_inline(&to, from, 1);
  }

Snippet from backtrace:

  #4 0x00007f5c1668a2b3
clang::CodeGen::CodeGenModule::getNaturalTypeAlignment(clang::QualType,
clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*, bool)
(/usr/bin/../lib/libclang-cpp.so.11+0x1bd82b3)
  #5 0x00007f5c1648cc42
clang::CodeGen::CodeGenFunction::EmitPointerWithAlignment(clang::Expr const*,
clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*)
(/usr/bin/../lib/libclang-cpp.so.11+0x19dac42)
  #6 0x00007f5c163cca99
clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned
int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot)
(/usr/bin/../lib/libclang-cpp.so.11+0x191aa99)
  #7 0x00007f5c1649379e
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot) (/usr/bin/../lib/libclang-cpp.so.11+0x19e179e)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to