diff --git a/examples/stack_example.cpp b/examples/stack_example.cpp
index 795ceb100b829fb230ece51c954b9b6eda3f947e..7d97400273732abd785fe8e1c7475885320b4a51 100644
--- a/examples/stack_example.cpp
+++ b/examples/stack_example.cpp
@@ -37,6 +37,7 @@ void read(corsika::super_stupid::SuperStupidStack& s) {
   assert(s.GetSize() == 11); // stack has 11 particles
 
   HEPEnergyType total_energy;
+  int i = 0;
   for (const auto& p : s) {
     total_energy += p.GetEnergy();
     // particles are electrons with 1.5 GeV energy times i