From fa4150b633fa298d1aca08e8f3098d34a5ffaefd Mon Sep 17 00:00:00 2001 From: Andrew Pardoe Date: Thu, 24 Sep 2015 09:55:51 -0700 Subject: [PATCH] Added Discussion for ES.74 --- CppCoreGuidelines.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 6b321e7..39d4d7c 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -7243,6 +7243,10 @@ Avoid using the loop variable for other purposes after the loop. **Enforcement**: Warn when a variable modified inside the `for`-statement is declared outside the loop and not being used outside the loop. +**Discussion**: Scoping the loop induction variable to the loop body also helps code optimizers greatly. Recognizing that the induction variable +is only accessible in the loop body unblocks optimizations such as hoisting, strength reduction, loop-invariant code motion, etc. + + ### ES.75: Avoid `do`-statements