> Perls built with BorlandC++ for Win32 when run with:
> perl -we "print 4294967296,4294967297"
> print
> 01
>
> I tested both latest snapshot and 5.6.0 version - the same result.
> :(
> I've found this because of some additional tests that were added into
> op/arith.t
>
> Same perls compiled with MSVC++ behave correctly.
>
> I will perform some deeper analyzis.
Analyzis discovered something that looks like bug in C compiler (in CRT).
Following program:
#include <errno.h>
#define TEST(a) \
uv = strtoul(a, (char**)0, 10); \
printf("str=%s uv=%u errno=%d\n",a,uv,errno);
void main()
{
unsigned int uv;
TEST("4294967295");
TEST("4294967296");
TEST("4294967297");
TEST("42949672950");
TEST("42949672960");
TEST("42949672970");
TEST("42949673970");
}
outputs:
str=4294967295 uv=4294967295 errno=0
str=4294967296 uv=0 errno=0
str=4294967297 uv=1 errno=0
str=42949672950 uv=4294967295 errno=34
str=42949672960 uv=0 errno=0
str=42949672970 uv=10 errno=0
str=42949673970 uv=4294967295 errno=34
Tested with BorlandC++ versions 5.2 and 5.5.1 -- exactly same output.
I can not guess when "strtoul" sets errno, and when it's not.
And code in "toke.c", function "Perl_scan_num" relies on fact that errno
will be set to non-zero if overflow occured.
> Can anyone share experience with that? Where should I begin bug hunting?
Now, can anyone suggest a way to work around this?
undefine "Strtol" and "Strtoul" ?
I've already reported a couple of bugs to Borland, and this is probably an
opportunity to do that once again.
:(
Best wishes,
<!ENTITY Vadim REALLIFE "St.Petersburg, Russia">
&Vadim;
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Thread Previous
|
Thread Next