Use of goto statements makes code more difficult to understand and maintain. Consequently, the use of goto statements is deprecated except as a mechanism for breaking out of multiple nested loops. This rule identifies any goto statements that are called directly or from a single nested loop as violations.

In most cases you should replace the goto statement in the highlighted code with an alternative jump statement (break, continue or return). In deeply nested loops you may need to use a goto statement because the break statement only exits from one level of the loop.

  • AV Rule 189, Joint Strike Fighter Air Vehicle C++ Coding Standards. Lockheed Martin Corporation, 2005.
  • A Case against the GO TO Statement (EWD-215).
  • MSDN Library: goto Statement (C++).
  • Mats Henricson and Erik Nyquist, Industrial Strength C++, published by Prentice Hall PTR (1997). Chapter 4: Control Flow, Rule 4.6 (PDF).
  • www.cplusplus.com Control Structures