Skip to content

Bug in operator x ? #4577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
p5pRT opened this issue Nov 13, 2001 · 10 comments
Closed

Bug in operator x ? #4577

p5pRT opened this issue Nov 13, 2001 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 13, 2001

Migrated from rt.perl.org#7902 (status was 'resolved')

Searchable as RT7902$

@p5pRT
Copy link
Author

p5pRT commented Nov 13, 2001

From @rgs

With bleadperl :

$ perl5.7.2 -le '$x=[("foo") x 2];print"<@​$x>"'
<foo >

With 5.6.1 :

$ perl5.6.1 -le '$x=[("foo") x 2];print"<@​$x>"'
<foo foo>

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.7.2:

Configured by rafael at Tue Nov 13 09:32:21 CET 2001.

Summary of my perl5 (revision 5.0 version 7 subversion 2 patch 12961) configuration:
  Platform:
    osname=linux, osvers=2.2.12-20, archname=i686-linux
    uname='linux rafael.kazibao.net 2.2.12-20 #1 mon sep 27 10:40:35 edt 1999 i686 unknown '
    config_args='-des -Dusedevel -Dprefix=/opt/perl'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    DEVEL12958


@INC for perl v5.7.2:
    /home/rafael/perllib
    /opt/perl/lib/5.7.2/i686-linux
    /opt/perl/lib/5.7.2
    /opt/perl/lib/site_perl/5.7.2/i686-linux
    /opt/perl/lib/site_perl/5.7.2
    /opt/perl/lib/site_perl
    .


Environment for perl v5.7.2:
    HOME=/home/rafael
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=en_US
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/rafael/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/apache/bin:/usr/local/java/jdk1.3.0_02/bin:/opt/perl/bin
    PERLLIB=/home/rafael/perllib
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2001

From @schwern

--- t/op/repeat.t 2001/11/14 18​:37​:14 1.1
+++ t/op/repeat.t 2001/11/14 18​:55​:45
@​@​ -1,48 +1,52 @​@​
#!./perl

-# $RCSfile​: repeat.t,v $$Revision​: 1.1 $$Date​: 2001/11/14 18​:37​:14 $
+BEGIN {
+ chdir 't' if -d 't';
+ @​INC = '../lib';
+}

-print "1..23\n";
+require './test.pl';
+plan(tests => 24);

# compile time

-if ('-' x 5 eq '-----') {print "ok 1\n";} else {print "not ok 1\n";}
-if ('-' x 1 eq '-') {print "ok 2\n";} else {print "not ok 2\n";}
-if ('-' x 0 eq '') {print "ok 3\n";} else {print "not ok 3\n";}
+is('-' x 5, '-----', 'compile time x');
+is('-' x 1, '-', ' x 1');
+is('-' x 0, '', ' x 0');

-if ('ab' x 3 eq 'ababab') {print "ok 4\n";} else {print "not ok 4\n";}
+is('ab' x 3, 'ababab', ' more than one char');

# run time

$a = '-';
-if ($a x 5 eq '-----') {print "ok 5\n";} else {print "not ok 5\n";}
-if ($a x 1 eq '-') {print "ok 6\n";} else {print "not ok 6\n";}
-if ($a x 0 eq '') {print "ok 7\n";} else {print "not ok 7\n";}
+is($a x 5, '-----', 'run time x');
+is($a x 1, '-', ' x 1');
+is($a x 0, '', ' x 0');

$a = 'ab';
-if ($a x 3 eq 'ababab') {print "ok 8\n";} else {print "not ok 8\n";}
+is($a x 3, 'ababab', ' more than one char');

$a = 'xyz';
$a x= 2;
-if ($a eq 'xyzxyz') {print "ok 9\n";} else {print "not ok 9\n";}
+is($a, 'xyzxyz', 'x=2');
$a x= 1;
-if ($a eq 'xyzxyz') {print "ok 10\n";} else {print "not ok 10\n";}
+is($a, 'xyzxyz', 'x=1');
$a x= 0;
-if ($a eq '') {print "ok 11\n";} else {print "not ok 11\n";}
+is($a, '', 'x=0');

@​x = (1,2,3);

-print join('', @​x x 4) eq '3333' ? "ok 12\n" : "not ok 12\n";
-print join('', (@​x) x 4) eq '123123123123' ? "ok 13\n" : "not ok 13\n";
-print join('', (@​x,()) x 4) eq '123123123123' ? "ok 14\n" : "not ok 14\n";
-print join('', (@​x,1) x 4) eq '1231123112311231' ? "ok 15\n" : "not ok 15\n";
-print join('​:', () x 4) eq '' ? "ok 16\n" : "not ok 16\n";
-print join('​:', (9) x 4) eq '9​:9​:9​:9' ? "ok 17\n" : "not ok 17\n";
-print join('​:', (9,9) x 4) eq '9​:9​:9​:9​:9​:9​:9​:9' ? "ok 18\n" : "not ok 18\n";
-print join('', (split(//,"123")) x 2) eq '123123' ? "ok 19\n" : "not ok 19\n";
+is(join('', @​x x 4), '3333', '@​x x Y');
+is(join('', (@​x) x 4), '123123123123', '(@​x) x Y');
+is(join('', (@​x,()) x 4), '123123123123', '(@​x,()) x Y');
+is(join('', (@​x,1) x 4), '1231123112311231', '(@​x,1) x Y');
+is(join('​:', () x 4), '', '() x Y');
+is(join('​:', (9) x 4), '9​:9​:9​:9', '(X) x Y');
+is(join('​:', (9,9) x 4), '9​:9​:9​:9​:9​:9​:9​:9', '(X,X) x Y');
+is(join('', (split(//,"123")) x 2), '123123', 'split and x');

-#
-# The test #20 is actually testing for Digital C compiler optimizer bug,
+
+# This test is actually testing for Digital C compiler optimizer bug,
# present in Dec C versions 5.* and 6.0 (used in Digital UNIX and VMS),
# found in December 1998. The bug was reported to Digital^WCompaq as
# DECC 2745 (21-Dec-1998)
@​@​ -95,7 +99,8 @​@​
#
# jhi@​iki.fi
#
-print "\xdd" x 24 eq "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" ? "ok 20\n" : "not ok 20\n";
+is("\xdd" x 24, "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", 'Dec C bug');
+

# When we use a list repeat in a scalar context, it behaves like
# a scalar repeat. Make sure that works properly, and doesn't leave
@​@​ -103,9 +108,17 @​@​
# -- robin@​kitsite.com

my ($x, $y) = scalar ((1,2)x2);
-print $x eq "22" ? "ok 21\n" : "not ok 21\n";
-print !defined $y ? "ok 22\n" : "not ok 22\n";
+is($x, "22", 'list repeat in scalar context');
+is($y, undef, ' no extra values on stack');

# Make sure the stack doesn't get truncated too much - the left
# operand of the eq binop needs to remain!
-print (77 eq scalar ((1,7)x2) ? "ok 23\n" : "not ok 23\n");
+is(77, scalar ((1,7)x2), 'stack truncation');
+
+
+# perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
+{
+ local $TODO = 'list repeat in anon array ref broken [ID 20011113.110]';
+ my $x= [("foo") x 1];
+ is( join('', @​$x), 'foofoo' );
+}

--

Michael G. Schwern <schwern@​pobox.com> http​://www.pobox.com/~schwern/
Perl6 Quality Assurance <perl-qa@​perl.org> Kwalitee Is Job One
Death? Its like being on holiday with a group of Germans.

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2001

From @schwern

Err, 'use'. My laywer informs me it's not yet possible to sue code
libraries for damages.

--

Michael G. Schwern <schwern@​pobox.com> http​://www.pobox.com/~schwern/
Perl6 Quality Assurance <perl-qa@​perl.org> Kwalitee Is Job One
An official "I want James Earl Jones' cock up my ass" t-shirt.
  http​://www.goats/com/archive/010303.html

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2001

From @jhi

I can't sue this... doth not apply even with the potent spell, patch -l.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2001

From @schwern

Lemme guess, line wrapping again? I have a bad feeling that perlbug
is mangling patches.

Here it is again

Inline Patch
--- t/op/repeat.t	Sat Mar 24 11:24:28 2001
+++ t/op/repeat.t	Wed Nov 14 13:55:45 2001
@@ -1,48 +1,52 @@
 #!./perl
 
-# $RCSfile: repeat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:21 $
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+}
 
-print "1..23\n";
+require './test.pl';
+plan(tests => 24);
 
 # compile time
 
-if ('-' x 5 eq '-----') {print "ok 1\n";} else {print "not ok 1\n";}
-if ('-' x 1 eq '-') {print "ok 2\n";} else {print "not ok 2\n";}
-if ('-' x 0 eq '') {print "ok 3\n";} else {print "not ok 3\n";}
+is('-' x 5, '-----',    'compile time x');
+is('-' x 1, '-',        '  x 1');
+is('-' x 0, '',         '  x 0');
 
-if ('ab' x 3 eq 'ababab') {print "ok 4\n";} else {print "not ok 4\n";}
+is('ab' x 3, 'ababab',  '  more than one char');
 
 # run time
 
 $a = '-';
-if ($a x 5 eq '-----') {print "ok 5\n";} else {print "not ok 5\n";}
-if ($a x 1 eq '-') {print "ok 6\n";} else {print "not ok 6\n";}
-if ($a x 0 eq '') {print "ok 7\n";} else {print "not ok 7\n";}
+is($a x 5, '-----',     'run time x');
+is($a x 1, '-',         '  x 1');
+is($a x 0, '',          '  x 0');
 
 $a = 'ab';
-if ($a x 3 eq 'ababab') {print "ok 8\n";} else {print "not ok 8\n";}
+is($a x 3, 'ababab',    '  more than one char');
 
 $a = 'xyz';
 $a x= 2;
-if ($a eq 'xyzxyz') {print "ok 9\n";} else {print "not ok 9\n";}
+is($a, 'xyzxyz',        'x=2');
 $a x= 1;
-if ($a eq 'xyzxyz') {print "ok 10\n";} else {print "not ok 10\n";}
+is($a, 'xyzxyz',        'x=1');
 $a x= 0;
-if ($a eq '') {print "ok 11\n";} else {print "not ok 11\n";}
+is($a, '',              'x=0');
 
 @x = (1,2,3);
 
-print join('', @x x 4) eq '3333' ? "ok 12\n" : "not ok 12\n";
-print join('', (@x) x 4) eq '123123123123' ? "ok 13\n" : "not ok 13\n";
-print join('', (@x,()) x 4) eq '123123123123' ? "ok 14\n" : "not ok 14\n";
-print join('', (@x,1) x 4) eq '1231123112311231' ? "ok 15\n" : "not ok 15\n";
-print join(':', () x 4) eq '' ? "ok 16\n" : "not ok 16\n";
-print join(':', (9) x 4) eq '9:9:9:9' ? "ok 17\n" : "not ok 17\n";
-print join(':', (9,9) x 4) eq '9:9:9:9:9:9:9:9' ? "ok 18\n" : "not ok 18\n";
-print join('', (split(//,"123")) x 2) eq '123123' ? "ok 19\n" : "not ok 19\n";
+is(join('', @x x 4),        '3333',                 '@x x Y');
+is(join('', (@x) x 4),      '123123123123',         '(@x) x Y');
+is(join('', (@x,()) x 4),   '123123123123',         '(@x,()) x Y');
+is(join('', (@x,1) x 4),    '1231123112311231',     '(@x,1) x Y');
+is(join(':', () x 4),       '',                     '() x Y');
+is(join(':', (9) x 4),      '9:9:9:9',              '(X) x Y');
+is(join(':', (9,9) x 4),    '9:9:9:9:9:9:9:9',      '(X,X) x Y');
+is(join('', (split(//,"123")) x 2), '123123',       'split and x');
 
-#
-# The test #20 is actually testing for Digital C compiler optimizer bug,
+
+# This test is actually testing for Digital C compiler optimizer bug,
 # present in Dec C versions 5.* and 6.0 (used in Digital UNIX and VMS),
 # found in December 1998.  The bug was reported to Digital^WCompaq as
 #     DECC 2745 (21-Dec-1998)
@@ -95,7 +99,8 @@
 #
 # [email protected]
 #
-print "\xdd" x 24 eq "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" ? "ok 20\n" : "not ok 20\n";
+is("\xdd" x 24, "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", 'Dec C bug');
+
 
 # When we use a list repeat in a scalar context, it behaves like
 # a scalar repeat. Make sure that works properly, and doesn't leave
@@ -103,9 +108,17 @@
 #  -- [email protected]
 
 my ($x, $y) = scalar ((1,2)x2);
-print $x eq "22"  ? "ok 21\n" : "not ok 21\n";
-print !defined $y ? "ok 22\n" : "not ok 22\n";
+is($x, "22",    'list repeat in scalar context');
+is($y, undef,   '  no extra values on stack');
 
 # Make sure the stack doesn't get truncated too much - the left
 # operand of the eq binop needs to remain!
-print (77 eq scalar ((1,7)x2) ? "ok 23\n" : "not ok 23\n");
+is(77, scalar ((1,7)x2),    'stack truncation');
+
+
+# perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
+{
+    local $TODO = 'list repeat in anon array ref broken [ID 20011113.110]';
+    my $x= [("foo") x 1];
+    is( join('', @$x), 'foofoo' );
+}


-- 

Michael G. Schwern <schwern@​pobox.com> http​://www.pobox.com/~schwern/
Perl6 Quality Assurance <perl-qa@​perl.org> Kwalitee Is Job One
They just don't make any good porn music anymore, do they?
  - WXDX DJ refering to "More, More, More"

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2001

From @jhi

Much better now, thanks.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2002

From @jhi

This got fixed for Perl 5.8.0, marking as resolved.

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2002

@jhi - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Nov 29, 2002
@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2013

From @cpansprout

On Thu Nov 28 16​:40​:23 2002, jhi wrote​:

This got fixed for Perl 5.8.0, marking as resolved.

It was fixed by change #13077, aka 976c8a3.

It reverted change #11635 (e30acc1), which was supposed to fix bug
20010809.028 aka #7505.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2013

From [Unknown Contact. See original ticket]

On Thu Nov 28 16​:40​:23 2002, jhi wrote​:

This got fixed for Perl 5.8.0, marking as resolved.

It was fixed by change #13077, aka 976c8a3.

It reverted change #11635 (e30acc1), which was supposed to fix bug
20010809.028 aka #7505.

--

Father Chrysostomos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant