Defect Report #079

Submission Date: 03 Dec 93
Submittor: WG14
Source: Clive Feather
Question
Item 16 - constancy of system library function addresses
(These questions approach the same problem from three slightly different directions.)
  1. If a pointer to a given standard library function (say strlen) is evaluated in two different translation units, and the pointers compared, must they compare equal?
  2. Can a conforming implementation declare a standard library function as having internal linkage, or must the identifiers with file scope declared in standard headers have external linkage?
  3. If the contents of the header <string.h> include the following definition of strlen, is the implementation conforming?
    static size_t strlen (const char *__s)
    {
    size_t __len = 0;

    while (*__s++)
    __len++;
    return __len;
    }
Response
Since the answer to question (b) is needed for question (a) it is given first.
b) Since, according to the fourth item in subclause 7.1.3, the library function prototypes are implicitly extern, the standard library functions have external linkage.
a) If the usage of strlen is such that standard library functions are referred to, the pointers must compare equal by the requirements of subclauses 5.1.1.2 and 6.1.2.2.
c) The contents of standard headers are implementation-defined. For instance, they may contain code written in other languages. It is not the job of this Committee to mandate implementation. Whatever their contents, including a standard header must achieve the effects required by the C Standard.
Previous Defect Report < - > Next Defect Report