diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp --- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -309,6 +309,9 @@ return false; this->emitCleanup(); return this->emitRet(*ReturnType, RS); + } else if (RE->getType()->isVoidType()) { + if (!this->visit(RE)) + return false; } else { // RVO - construct the value in the return location. if (!this->emitRVOPtr(RE)) diff --git a/clang/test/AST/Interp/functions.cpp b/clang/test/AST/Interp/functions.cpp --- a/clang/test/AST/Interp/functions.cpp +++ b/clang/test/AST/Interp/functions.cpp @@ -291,3 +291,12 @@ // ref-note {{read of variable whose lifetime has ended}} \ // expected-error {{not an integral constant expression}} } + +namespace VoidReturn { + /// ReturnStmt with an expression in a void function used to cause problems. + constexpr void bar() {} + constexpr void foo() { + return bar(); + } + static_assert((foo(),1) == 1, ""); +}