[llvm-bugs] [Bug 43154] New: In CodeGen::CodeGenFunction::EmitCallArgs: Assertion `[...] && "type mismatch in call argument!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 28 12:50:58 PDT 2019


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

            Bug ID: 43154
           Summary: In CodeGen::CodeGenFunction::EmitCallArgs: Assertion
                    `[...] && "type mismatch in call argument!"' failed
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaronpuchert at alice-dsl.net
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Compiling the following with "-std=c++17" (or "-cc1 -emit-llvm -std=c++17
-fexceptions") fails with an assertion:

void f(void (&fn)());

void g() noexcept;

void h() {
    f(g);
}

The trace is:

1.      <eof> parser at end of file
2.      codegen-crash.cpp:5:6: LLVM IR generation of declaration 'h'
3.      codegen-crash.cpp:5:6: Generating code for declaration 'h'

When emitting the call to f, the types of parameters and arguments are
compared. Here we have an argument of type 'void () noexcept', but the function
expects 'void ()'. (With C++17, noexcept is part of the type. There is no
assertion failure with older C++ standards.)

Indeed, there should be an implicit cast for the argument in the AST, but there
isn't (I omitted addresses for brevity):

`-FunctionDecl <line:5:1, line:7:1> line:5:6 h 'void ()'
  `-CompoundStmt <col:10, line:7:1>
    `-CallExpr <line:6:5, col:8> 'void'
      |-ImplicitCastExpr <col:5> 'void (*)(void (&)())'
<FunctionToPointerDecay>
      | `-DeclRefExpr <col:5> 'void (void (&)())' lvalue Function 0x1d69b98 'f'
'void (void (&)())'
      `-DeclRefExpr <col:7> 'void () noexcept' lvalue Function 0x1d69ce0 'g'
'void () noexcept'

Not sure which kind of implicit cast this would be in OperationsKind.def, but
the standard mentions it explicitly in [conv.fctptr]: "A prvalue of type
“pointer to noexcept function” can be converted to a prvalue of type “pointer
to function”."

-- 
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/20190828/bc4d0db1/attachment.html>


More information about the llvm-bugs mailing list