David Ledger - 2020-11-19

Gday,

The following outlines some issues:

The following results in a cppcheck crash. var->valueType() can be nullptr. Inside symboldatabase.cpp

        out << " access=\""         << accessControlToString(var->mAccess) << '\"';
        out << " scope=\""          << var->scope() << '\"';
        out << " constness=\""      << var->valueType()->constness << '\"'; // THIS
        out << " isArgument=\""     << var->isArgument() << '\"';
        out << " isArray=\""        << var->isArray() << '\"';

Also here in checkother.cpp:

    if (var->valueType()->type == ValueType::Type::CONTAINER) {
    } else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
        // Ensure that it is a large object.
        if (!var->type()->classScope)
            inconclusive = true;
        else if (estimateSize(var->type(), mSettings, symbolDatabase) <= 2 * mSettings->sizeof_pointer)
            continue;
    } else
        continue;

The code that reproduces it is something like this, tough to reproduce outside of my project...

struct Thing
{
    struct B
    {
        const Command Code;
    };
    union
    {
        B         Foo;
        bytes<1u> Bar;
    };

    Thing(decltype(Bar) args) noexcept : Bar{ args } {}
};

The variable args doesn't get a valueType.

 

Last edit: David Ledger 2020-11-19