Skip to content

Files

Latest commit

 

History

History
20 lines (12 loc) · 568 Bytes

runtime-invalid_increment.md

File metadata and controls

20 lines (12 loc) · 568 Bytes

Pattern: Use of postfix increment/decrement

Issue: -

Description

Use prefix form (++i) of the increment and decrement operators with iterators and other template objects. For example following function:

void increment_counter(int* count) {
*count++;
}

is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++ or *count += 1.

Further Reading