mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-26 20:30:06 +01:00
MSVC improvements and data truncation cleanup.
MSVC is timid about evaluating constexpr functions unless it has to, so the "TYPES" variables end up in read-write memory even though the optimizer removes the initializer. Making TYPES constexpr causes MSVC to try harder to initialize these variables at compile time, which also ends up completely removing the (named) variable from the final compiled binary. Fixed a data truncation warning being reported in ostream-test.
This commit is contained in:
committed by
Victor Zverovich
parent
728e4f5a8d
commit
550ef1d29d
@@ -1381,13 +1381,13 @@ class float_type_checker : private ErrorHandler {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ErrorHandler>
|
||||
template <typename ErrorHandler, typename CharType>
|
||||
class char_specs_checker : public ErrorHandler {
|
||||
private:
|
||||
char type_;
|
||||
CharType type_;
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh)
|
||||
FMT_CONSTEXPR char_specs_checker(CharType type, ErrorHandler eh)
|
||||
: ErrorHandler(eh), type_(type) {}
|
||||
|
||||
FMT_CONSTEXPR void on_int() {
|
||||
@@ -3110,8 +3110,10 @@ struct formatter<
|
||||
type_spec, internal::int_type_checker<decltype(eh)>(eh));
|
||||
break;
|
||||
case internal::char_type:
|
||||
handle_char_specs(specs_, internal::char_specs_checker<decltype(eh)>(
|
||||
type_spec, eh));
|
||||
handle_char_specs(
|
||||
specs_,
|
||||
internal::char_specs_checker<decltype(eh), decltype(type_spec)>(
|
||||
type_spec, eh));
|
||||
break;
|
||||
case internal::double_type:
|
||||
case internal::long_double_type:
|
||||
|
||||
Reference in New Issue
Block a user