Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-3396

Proposed rule: while(true) should be preferred over for(;;) for loop with no termination condition

    XMLWordPrintable

    Details

      Description

      Taken from: https://www.teamten.com/lawrence/style/notes.html

      Bad:   for (;;) ...
      Good:  while (1) ...
      Better:while (TRUE) ...
      

      The "while" is clearer. The "for" loop should be reserved when looping a variable from one value to another. It is safe to define FALSE as 0 and TRUE as 1.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            arseniy.zaostrovnykh Arseniy Zaostrovnykh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: