diff --git a/Control/xAODRootAccess/Root/Utils.cxx b/Control/xAODRootAccess/Root/Utils.cxx
index dd29fb06acc599e69012cd7b5eb44ac58fa1fe2b..dd1f6205d133d066391f86e5a991b1367100c924 100644
--- a/Control/xAODRootAccess/Root/Utils.cxx
+++ b/Control/xAODRootAccess/Root/Utils.cxx
@@ -320,7 +320,7 @@ namespace xAOD {
          const TObjArray * pBranches = tree->GetListOfBranches();
          const std::regex pattern( ".*" + pre + ".*" );
 
-         for( int i = 0; i <= pBranches->GetLast() ; ++i ) {
+         for( int i = 0, nLast = pBranches->GetLast(); i <= nLast; ++i ) {
             const std::string name = pBranches->At(i)->GetName();
 
             if( std::regex_match( name, pattern ) )