In C11 rules of reserved identifiers are defined in the library clause (clause 7). Hence, are rules of reserved identifiers irrelevant if library is not used?
Note: in C23 rules of reserved identifiers are defined in the language clause (clause 6) and in the library clause (clause 7). This may suggest that there was a defect regarding this aspect. Does anyone know the details?
In C11 rules of reserved identifiers are defined in the library clause (clause 7). Hence, are rules of reserved identifiers irrelevant if library is not used?
No.
C11 says this:
Each header declares or defines all identifiers listed in its associated subclause, and optionally declares or defines identifiers listed in its associated future library directions subclause and identifiers which are always reserved either for any use or for use as file scope identifiers.
- All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
- All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
- Each macro name in any of the following subclauses (including the future library directions) is reserved for use as specified if any of its associated headers is included; unless explicitly stated otherwise (see 7.1.4).
- All identifiers with external linkage in any of the following subclauses (including the future library directions) and errno are always reserved for use as identifiers with external linkage.184)
- Each identifier with file scope listed in any of the following subclauses (including the future library directions) is reserved for use as a macro name and as an identifier with file scope in the same name space if any of its associated headers is included.
No other identifiers are reserved.
(C11 7.1.3/1-2)
The formatting of the provision is a little awkward, but the spec explicitly differentiates between identifiers that are always reserved and those that are only conditionally reserved, depending on which headers are included. There is no reason to interpret "always" other than according to its ordinary English meaning. Identifiers that those provisions say are always reserved are reserved unconditionally. Regardless of the nature or contents of the program.
I note that it is possible to call standard library functions without including any standard header, so the reservations that are contingent on including headers don't necessarily speak directly to the question, but the unconditional reservation of "All identifiers with external linkage in any of the following subclauses" definitely does. It means that you cannot (definedly) define your own external functions with the same names as standard library functions even if in some sense you contrive not to use the corresponding standard library functions.
It may be that some of the motivation for these reservations is to avoid vectors for interference with standard library functions, and that may be why the provisions appear where they do in C11, but many of the provisions apply unconditionally.
in C23 rules of reserved identifiers are defined in the language clause (clause 6) and in the library clause (clause 7). This may suggest that there was a defect regarding this aspect. Does anyone know the details?
WG14's latest list of C DRs does not appear to contain any asserting a defect along the lines you seem to be proposing. However, although it was not presented as a defect per se, WG14 did accept the idea that the identifier reservations in C17 and below were too broad, as described in and corrected by document n2625 and subsequent updates. The changes specified here are where some of the language about reserved identifiers was moved from chapter 7 to chapter 6. Again, that move itself seems to be purely editorial.