<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 - Crash with __builtin_memcpy_inline when source is an array"
   href="https://bugs.llvm.org/show_bug.cgi?id=48294">48294</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash with __builtin_memcpy_inline when source is an array
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </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>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jasper.mattsson@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24208" name="attach_24208" title="Full backtrace from crash">attachment 24208</a> <a href="attachment.cgi?id=24208&action=edit" title="Full backtrace from crash">[details]</a></span>
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)</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>