Skip to content

MSVC: Conditional expression is constant warning when formatting tm with unicode disabled #4294

@edo9300

Description

@edo9300

When formatting a tm struct with unicode support disabled, MSVC outputs the warning C4127 on this row

if (detail::use_utf8 && loc != get_classic_locale()) {

this is a sample repro scenario

#define FMT_UNICODE 0
#include <fmt/core.h>
#include <fmt/chrono.h>
#include <ctime>

int main() {
	auto now = std::time(nullptr);
	fmt::format("[{:%Y-%m-%d %H:%M:%S}]", fmt::localtime(now));
	return 0;
}

(compile with /W4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions