diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8008d40c4d1..2ad9d487599 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3731,7 +3731,8 @@ bool Variable::arrayDimensions(const Settings& settings, bool& isContainer) // TODO: only perform when ValueFlow is enabled // TODO: collect timing information for this call? ValueFlow::valueFlowConstantFoldAST(const_cast(dimension_.tok), settings); - if (dimension_.tok && dimension_.tok->hasKnownIntValue()) { + if (dimension_.tok && (dimension_.tok->hasKnownIntValue() || + (dimension_.tok->isTemplateArg() && !dimension_.tok->values().empty()))) { dimension_.num = dimension_.tok->getKnownIntValue(); dimension_.known = true; } diff --git a/test/testother.cpp b/test/testother.cpp index 873ae8ef852..4dceade465e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11062,6 +11062,13 @@ class TestOther : public TestFixture { " C(A x_, B y_) : x(x_), y(y_) {}\n" "};\n"); ASSERT_EQUALS("", errout_str()); // don't crash + + check("template \n" // #13537 + " struct S {\n" + " T a[N];\n" + "};\n" + "void f(S s) {}\n"); + ASSERT_EQUALS("", errout_str()); } void checkComparisonFunctionIsAlwaysTrueOrFalse() {