Implementation-defined behavior¶
This document contains the implementation details of the implementation-defined behavior in libc++. The C++ standard mandates that implementation-defined behavior is documented.
Implementation-defined behavior¶
Updating the Time Zone Database¶
The C++ standard allows implementations to automatically update the remote time zone database. Libc++ opts not to do that. Instead calling
std::chrono::remote_version()will update the version information of the remote time zone database,std::chrono::reload_tzdb(), if needed, will update the entire remote time zone database.
This offers a way for users to update the remote time zone database and give them full control over the process.
[ostream.formatted.print]/3 A terminal capable of displaying Unicode¶
The C++ standard specifies that the manner in which a stream is determined to refer
to a terminal capable of displaying Unicode is implementation-defined. This is
used for std::print and similar functions taking an ostream& argument.
Libc++ determines that a stream is Unicode-capable terminal by:
First it determines whether the stream’s
rdbuf()has an underlyingFILE*. This istruein the following cases:The stream is
std::cout,std::cerr, orstd::clog.A
std::basic_filebuf<CharT, Traits>derived fromstd::filebuf.
The way to determine whether this
FILE*refers to a terminal capable of displaying Unicode is the same as specified for void vprint_unicode(FILE* stream, string_view fmt, format_args args);. This function is used for otherstd::printoverloads that don’t take anostream&argument.
[sf.cmath] Mathematical Special Functions: Large indices¶
Most functions within the Mathematical Special Functions section contain integral indices. The C++ standard specifies the result for larger indices as implementation-defined. Libc++ pursuits reasonable results by choosing the same formulas as for indices below that threshold. E.g.,
std::hermite(unsigned n, T x)forn >= 128
[filebuf.virtuals] Effect of calling basic_filebuf::setbuf with nonzero arguments¶
Libc++ uses the provided buffer as the underlying buffer for input and output, and does not discard that buffer even when the stream is closed.
[stringbuf.cons] Whether sequence pointers are initialized to null pointers¶
Libc++ does not initialize the pointers to null pointers. It resizes the buffer
to its capacity and uses that size. This means the SSO buffer of
std::string is used as initial output buffer.
[debugging.utility] is_debugger_present¶
Libc++ implements std::is_debugger_present() differently depending on the host platform:
Linux:
/proc/self/statusis read for theTracerPidentry and if it is equal to 0, returnsfalse. Otherwise, the command name of the tracer PID is looked up, and a best effort is made to identify whether the tracer process’ name is a recognized debugger: “gdb”, “gdbserver” or “lldb-server”. False is returned if it is not in this list.Darwin & FreeBSD:
sysctlis called to retrieve the current process information and check if theP_TRACEDflag is set in the returned info. On Darwin,kinfo_proc::kp_proc.p_flagis checked. On FreeBSD,kinfo_proc::ki_flagis checked.AIX: Reads the file
/proc/{current_pid}/status(subtituting current_pid for the process’ PID) into apstatus_tstructure, then checks if theSTRCflag is set inpstatus_t::pr_flag.Windows: Calls
IsDebuggerPresent().Default: Returns
false.
It is also defined as a weak symbol in the library to allow it to be replaceable, as per the standard, so a user may redefine it with their own implementation.
Listed in the index of implementation-defined behavior¶
The order of the entries matches the entries in the draft of the Standard.