Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Invoking getc() and putc() with stream arguments that have side effects may cause unexpected results because these functions may be implemented as macros, and the stream arguments to these macros may be evaluated more than once.

...

This example shows only the side-effect issue. The output differs depending on the character set. Consequently, it is important to make no assumptions about the order of the letters. For example, when run on a machine using an ASCII-derived code set such as ISO-8859 or Unicode, this code sample will print out the 26 lowercase letters of the English alphabet. However, if run with an EBCDIC-based code set, such as Codepage 037 or Codepage 285, punctuation marks or symbols may be output between the letters.

...

Using an expression that has side effects as the stream argument to getc() or putc() can result in unexpected behavior and possibly abnormal program termination.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

FIO41-C

lowLow

unlikelyUnlikely

mediumMedium

P2

L3

Automated Detection

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

9 S

Fully implemented

...