Bug 5625 – std.format unittest disabled

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2011-02-20T14:21:00Z
Last change time
2013-03-04T01:46:48Z
Keywords
wrong-code
Assigned to
yebblies
Creator
braddr

Comments

Comment #0 by braddr — 2011-02-20T14:21:04Z
Testing generated/linux/debug/64/unittest/std/format [email protected](3651): unittest failure
Comment #1 by braddr — 2011-03-20T03:21:43Z
Here's the reduced version of this bug. Larger than I'd like still, but is proving hard to reduce further. module bug; extern(C) int printf(const char *, ...); struct FormatSpec { char spec = 's'; bool flHash = false; // unused function, but if removed hides the bug void writeUpToNextSpec(OutputRange)(OutputRange writer) {} } void formatValue(long val, ref FormatSpec f) { char[] w; long arg = val; // always true, but removing conditional hides the bug uint base = f.spec == 's' ? 10 : 0; // if moved above base line, or merged with the declaration, hides the bug arg = -arg; char buffer[64]; // 64 bits in base 2 at most uint i = buffer.length; auto n = cast(ulong) arg; do { --i; buffer[i] = cast(char) (n % base); n /= base; if (buffer[i] < 10) buffer[i] += '0'; else buffer[i] += 'A' - 10; } while (n); // unused, but if removed hides the bug; sizediff_t spacesToPrint = (base == 16 && f.flHash && arg); // always true, but needs the conditional to show the bug if (arg) w = buffer[i .. $]; // the code to append the '-' to w was removable, so '999' // really is the expected results printf("w = %.*s\n", w.length, w.ptr); assert(w == "999"); } int main() { auto spec = FormatSpec(); formatValue(-999L, spec); return 0; }
Comment #2 by braddr — 2011-03-20T03:35:07Z
For that reduction, it needs both -m64 and -O to fail. Also, this likely isn't the only 64 bit bug related to std.format. I'm not sure why, but the reduction in comment 1 isn't the same as the line number in comment 0 points to. The one at line 3651 didn't fail for me when I started reducing the bug but is right now.
Comment #3 by braddr — 2012-01-01T21:02:22Z
The bug in comment 1 has been fixed. The next bug related to creal passing in vararg's. The repro case: module bugformat; import core.vararg; void bar(TypeInfo[] arguments, va_list argptr) { creal values = va_arg!(cdouble)(argptr); assert(values == 1.2 + 3.4i, "value didn't make it through intact"); } void foo(...) { bar(_arguments, _argptr); } int main() { foo(1.2 + 3.4i); return 0; }
Comment #4 by yebblies — 2012-02-26T08:36:47Z
I think I've got this. The complex xmm codegen is pretty awful.
Comment #5 by github-bugzilla — 2012-12-08T19:42:09Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/9db098b69a7c2057152a6940cac368264a5e0869 [Fixup] Now, bug 5625 might not be directly related to std.string.format
Comment #6 by clugdbug — 2013-03-04T01:46:48Z
The original bug in this report has been fixed. I've moved the independent bug reported in comment 3 into a new bug 9643.