Commit cd3964eb authored by Patrick Palka's avatar Patrick Palka
Browse files

libstdc++: Stop defining _GLIBCXX_ASSERTIONS in floating_to_chars.cc

Assertions were originally enabled in the compiled-in floating-point
std::to_chars implementation to help shake out any bugs, but they
apparently impose a significant performance penalty, most notably for
the hex formatting which is around 25% slower with assertions enabled.
This seems too high a cost for unconditionally enabling them.

The newly added calls to __builtin_unreachable work around the compiler
no longer knowing that the set of valid values of 'fmt' is limited (which
was previously upheld by an assert).

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (_GLIBCXX_ASSERTIONS): Don't
	define.
	(__floating_to_chars_shortest): Add __builtin_unreachable calls to
	squelch false-positive -Wmaybe-uninitialized and -Wreturn-type
	warnings.
	(__floating_to_chars_precision): Likewise.
parent fdb3f82f
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment