Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: minor edits. i removed the thing about automated detection because it was in the wrong place and was sort of self-evident anyway

...

Noncompliant Code Example

The following well-formed, but noncompliant, This noncompliant code example allows a constant object to be modified:

...

If ipp, ip, and i are declared as automatic variables, this example compiles without warning with Microsoft Visual Studio 2013 when compiled in C mode (/TC) and the resulting program changes the value of i. GCC 4.8.1 generates a warning but compiles, and the resulting program changes the value of i.

...

If the intent is that the value of i is not meant to change, then do not write noncompliant code that attempts to modify it.  This may require relying on additional analysis tools to catch constraint violations in cases where the compiler does not emit a diagnostic.   

Risk Assessment

Modifying constant objects through non-constant references results in undefined behavior.

...