http://d.puremagic.com/issues/show_bug.cgi?id=5625
--- Comment #1 from Brad Roberts <bra...@puremagic.com> 2011-03-20 03:21:43 PDT --- 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; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------