Versions Compared

Key

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

Some funcitons functions return a pointer to a object that cannot be modified without causing undefined behavior. These functions include the standard getenv(), setlocale(), localeconv(), and localeconvstrerror() functions.

Wiki Markup
C99 \[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] defines {{getenv}} as follows:

...

Altering the string returned by setlocale() or the structure returned by localeconv() results in undefined behavior.

Wiki Markup
Finally, C99 Section 7.21.6.2 \[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] states:

The strerror function returns a pointer to the string, the contents of which are locale specific. The array pointed to shall not be modified by the program, but may be
overwritten by a subsequent call to the strerror function.

Altering the string returned by strerror() results in undefined behavior.

Noncompliant Code Example

...

Wiki Markup
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.2011.41.51, "The“The {{getenvsetlocale}} function"function”, Section 7.11.12.1, “The {{setlocalelocaleconv}} function”, Section 7.1120.2.1, “The4.5, "The {{getenv}} function", Section 7.21.6.2 The {{localeconvstrerror}} function”function
\[[Open Group 04|AA. C References#Open Group 04]\] [getenv|http://www.opengroup.org/onlinepubs/000095399/functions/getenv.html], [setlocale|http://www.opengroup.org/onlinepubs/009695399/functions/setlocale.html], [localeconv|http://www.opengroup.org/onlinepubs/009695399/functions/localeconv.html]

...