Subject: | an odd test in vutil.c |
Date: | Fri, 09 May 2014 11:52:45 -0400 |
To: | bug-version [...] rt.cpan.org |
From: | Jarkko Hietaniemi <jhi [...] iki.fi> |
(from blead vutil.c)
354 if ( (PERL_ABS(orev) > PERL_ABS(rev))
355 || (PERL_ABS(rev) > VERSION_MAX )) {
The test in line 355 can never be true -- in most platforms.
The rev is I32, so it cannot ever be > VERSION_MAX:
#define VERSION_MAX 0x7FFFFFFF
I do see a way for it to be true, in IL(P)64, though... when I32 is
actually I64.
So (1) one way to bombproof it:
if ( (PERL_ABS(orev) > PERL_ABS(rev))
#if INTSIZE == 8
|| (PERL_ABS(rev) > VERSION_MAX)
#endif
) {
...or, (2) define VERSION_MAX to be (((I32)~0)>>1) ?
...or, (3) maybe some lower limit than the signed max value of the type?
...or, (4) maybe the test is not useful at all ?