except that if the value of timeptr->tm_year is outside the range [-2899, 8099] (and thus the represented year will not fit into four characters) it is replaced by up to 4 implementation-defined characters.
From 7.1.4 paragraph 1:If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined.Thus, asctime() may exhibit undefined behavior if any of the members of timeptr produce undefined behavior in the sample algorithm (for example, if the timeptr->tm_wday is outside the range 0 to 6 the function may index beyond the end of an array).As always, the range of undefined behavior permitted includes:
- Corrupting memory
- Aborting the program
- Range checking the argument and returning a failure indicator (e.g., a null pointer)
- Returning truncated results within the traditional 26 byte buffer.
There is no consensus to make the suggested change or any change along this line.
Previous Defect Report < - > Next Defect Report