[comp.lang.perl] Perl level 41 Fails lib bigint test. Test Case included.

blu@millipore.com (Brian Utterback) (11/17/90)

As has already been noted, perl level 41 fails the test.  There seems to be
a problem with the cmp operator and possibly the || op as well.
I distilled the failing test down to the following test cases.  I think this
illustrates the problem.  Unfortunately I am not a Perl internals hacker
so I can't go any further.  I am great at getting test cases though.

Perl Script follows:
#!/bin/perl
print (-123 cmp ',');
print "\n";
print (0||516);
print "\n";
print (-123 cmp -124);
print "\n";


This script print out the following:
712
516
-26876

Now unless I am wrong, cmp should only ever return -1, 0 or 1 and isn't that 
supposed to be true of ||?  It is clear that the bigint lib depends on 
cmp only returning 0, -1 or 1.
-- 
Brian Utterback, Millipore Corporation, 75G Wiggins Ave., Bedford Ma. 01730
Work:617-275-9200x8245, Home:603-891-2536
INTERNET:: blu@millipore.millipore.com
UUCP:: {samsung,cg-atla,merk,wang,bu-tyng}!millipore!blu

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (11/17/90)

In article <1990Nov16.192134.15095@millipore.com> blu@millipore.com (Brian Utterback) writes:
: As has already been noted, perl level 41 fails the test.  There seems to be
: a problem with the cmp operator and possibly the || op as well.

Yes, cmp was assuming that memcmp returned -1, 0 or 1 when it's not
documented to do so.  >>patch42.

The || behavior is correct.  $a || $b || $c will return the first true value.

Larry