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