[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: This Fortnight on perl5-porters - 28 September-12 October 2008
David Landgren <david@landgren.net> wrote:
:This Fortnight on perl5-porters - 28 September-12 October 2008
[...]
:"Perl_newSVpvf("%lld")" is broken
:
: One other item that fell out of the Y2038+ code was that, on 32-bit
: platforms, "printf("%lld\n", 2**32)" gives a result of -1. Michael and
: admitted to being terrified by the code and hoped someone else could
: dig down through it and figure out where the problem lay.
:
: quad wrangle
: http://xrl.us/oudxw
Apologies if this has already been addressed: I'm mostly 1-2 weeks behind
on email these days.
The problem is combo-ifdefs. First we get this:
case 'l':
#if defined(HAS_QUAD) || defined(HAS_LONG_DOUBLE)
if (*(q + 1) == 'l') { /* lld, llf */
intsize = 'q';
q += 2;
break;
}
#endif
and then we get this (for the %d case):
default: iv = tiv; break;
#ifdef HAS_QUAD
case 'q': iv = (Quad_t)tiv; break;
#endif
So when HAS_LONG_DOUBLE but not HAS_QUAD, we set intsize='q', but then
silently go to the default (%d) case at the point we consume it.
It should rather do the same as the long double case, i.e.:
case 'q':
#ifdef HAS_QUAD
iv = (Quad_t)tiv; break;
#else
goto unknown;
#endif
.. and the same logic needs to be repeated in many #ifdef HAS_QUAD places
(and the HAS_LONG_DOUBLE places should be checked too, for completeness).
Patching just the one place fixes it for me:
zen% ./perl -Ilib -e 'printf "%lld\n", 4294967296'
%lld
zen%
Sorry I don't have time to generate a full patch right now, I hope this
info is enough.
(It is also arguable that "%lld" isn't the most useful output, but if that
is changed thought should be given to making the analogous change for %llf.)
Hugo
- References to:
-
David Landgren <david@landgren.net>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]