Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp @@ -65,6 +65,10 @@ const MatchFinder::MatchResult &Result) { const auto *Matched = Result.Nodes.getNodeAs("expr"); const auto *IndexExpr = Result.Nodes.getNodeAs("index"); + + if (IndexExpr->isValueDependent()) + return; // We check in the specialization. + llvm::APSInt Index; if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr, /*isEvaluated=*/true)) { Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp +++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp @@ -0,0 +1,11 @@ +// RUN: clang-tidy %s -checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | count 0 + +// Note: this test expects no diagnostics, but FileCheck cannot handle that, +// hence the use of | count 0. +template struct B { + int get() { + // The next line used to crash the check (in C++03 mode only). + return x[index]; + } + int x[3]; +};