This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [ubsan] Fix printing of floats in mingw mode
ClosedPublic

Authored by mstorsjo on Apr 12 2023, 8:00 AM.

Details

Summary

In mingw mode on x86, long doubles are 80 bit - while MSVC mode uses
long doubles that are equal to regular doubles (on all architectures).

In the case of this formatting function, we're calling a MS CRT
provided printf function which interprets long doubles as 64 bit.

Since the long doubles are equal to regular doubles on all MSVC
platforms, just use regular double formatting. For MSVC environments
there's no difference, but for mingw environments, this avoids the
ambiguity.

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 12 2023, 8:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 8:00 AM
mstorsjo requested review of this revision.Apr 12 2023, 8:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 8:00 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Apr 12 2023, 10:06 AM
This revision is now accepted and ready to land.Apr 12 2023, 10:06 AM
MaskRay added inline comments.
compiler-rt/lib/ubsan/ubsan_diag.cpp
218

In comments we prefer more canonical spelling. MinGW seems more canonical and also more popular than mingw in comments?

mstorsjo added inline comments.Apr 12 2023, 11:21 AM
compiler-rt/lib/ubsan/ubsan_diag.cpp
218

Sure, I can change it that way, as that’s the canonical spelling.