Fix crash in checkPassByReference() (#4122)
This commit is contained in:
parent
1ed0d9ad92
commit
22a4fdb6c4
|
@ -1178,7 +1178,7 @@ static int estimateSize(const Type* type, const Settings* settings, const Symbol
|
|||
size = settings->sizeof_pointer;
|
||||
else if (var.type() && var.type()->classScope)
|
||||
size = estimateSize(var.type(), settings, symbolDatabase, recursionDepth+1);
|
||||
else if (var.valueType()->type == ValueType::Type::CONTAINER)
|
||||
else if (var.valueType() && var.valueType()->type == ValueType::Type::CONTAINER)
|
||||
size = 3 * settings->sizeof_pointer; // Just guess
|
||||
else
|
||||
size = symbolDatabase->sizeOfType(var.typeStartToken());
|
||||
|
|
|
@ -1816,6 +1816,13 @@ private:
|
|||
"void f(S s) {}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 's' should be passed by const reference.\n", errout.str());
|
||||
|
||||
check("union U {\n" // don't crash
|
||||
" int a;\n"
|
||||
" decltype(nullptr) b;\n"
|
||||
"};\n"
|
||||
"int* f(U u) { return u.b; }\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
Settings settings1;
|
||||
settings1.platform(Settings::Win64);
|
||||
check("using ui64 = unsigned __int64;\n"
|
||||
|
|
Loading…
Reference in New Issue