Mailing List Archive

(fwd) Perl bug/feature: vec and references
Path: news.umbc.edu!mabzug1
From: mabzug1@umbc.edu (Mordechai T. Abzug)
Newsgroups: comp.lang.perl.misc
Subject: Perl bug/feature: vec and references
Date: 29 Aug 1995 21:33:56 GMT
Organization: the Courts of Chaos
Lines: 25
Message-ID: <420144$ig3@news.umbc.edu>
NNTP-Posting-Host: ela02.gl.umbc.edu
NNTP-Posting-User: mabzug1
X-Newsreader: TIN [version 1.2 PL2]
Xref: news.umbc.edu comp.lang.perl.misc:5045

#good:
vec ($a, 0, 32) = 65; # works well;

#bad:
$foo = {};
vec ($foo->{'bar'}, 0, 32)=65; #dies miserably

#OK:
$foo = {};
$foo->{'bar'}='blatz';
vec ($foo->{'bar'}, 0, 32)=65; #proceeds normally.

In other words, although normal vectors don't require prior initialization,
referenced ones do.

Didn't see anything in perlref to explain this, but then, I'm no Perl hacker
(yet! ;> ) so I could've missed something subtle. Or even something
explicit.

(note: this happened on an SGI Indigo, running IRIX 5.3, under Perl5.001, if
that makes any difference).

--
-Mordechai T. Abzug
Homepage: http://www.gl.umbc.edu/~mabzug1 send email to: mabzug1@umbc.edu

--
-Mordechai T. Abzug
Homepage: http://www.gl.umbc.edu/~mabzug1 send email to: mabzug1@umbc.edu
Recursive, adj.; see Recursive
Re: (fwd) Perl bug/feature: vec and references [ In reply to ]
: Path: news.umbc.edu!mabzug1
: From: mabzug1@umbc.edu (Mordechai T. Abzug)
: Newsgroups: comp.lang.perl.misc
: Subject: Perl bug/feature: vec and references
: Date: 29 Aug 1995 21:33:56 GMT
: Organization: the Courts of Chaos
: Lines: 25
: Message-ID: <420144$ig3@news.umbc.edu>
: NNTP-Posting-Host: ela02.gl.umbc.edu
: NNTP-Posting-User: mabzug1
: X-Newsreader: TIN [version 1.2 PL2]
: Xref: news.umbc.edu comp.lang.perl.misc:5045
:
: #good:
: vec ($a, 0, 32) = 65; # works well;
:
: #bad:
: $foo = {};
: vec ($foo->{'bar'}, 0, 32)=65; #dies miserably
:
: #OK:
: $foo = {};
: $foo->{'bar'}='blatz';
: vec ($foo->{'bar'}, 0, 32)=65; #proceeds normally.
:
: In other words, although normal vectors don't require prior initialization,
: referenced ones do.
:
: Didn't see anything in perlref to explain this, but then, I'm no Perl hacker
: (yet! ;> ) so I could've missed something subtle. Or even something
: explicit.
:
: (note: this happened on an SGI Indigo, running IRIX 5.3, under Perl5.001, if
: that makes any difference).

I believe this is already in my bugs database, though it a slightly
different guise. See below.

But thanks. I appreciate it when people send small test cases like that.

Larry


*******************************************************************************


Bug NETaa13957 NL.perl Submitted 950411
NEW defect report perl, version 5.001
1 enclosure

"vec doesn't propagate lvalueness"

DETECTION INFORMATION
Detection method: customer use
Detected in phase: post release
Test program name:
Hardware:
Version of OS:
Problem severity: 2
Affects project:
Need fix by:
SUBMITTER INFORMATION
Submitter: David Couture
Organization: Computing and Network
Phone number:
Address: dc@vaccine

************ Problem (Added 950411 by dc) ***********
Path: netlabs!news.cerf.net!qualcomm.com!ihnp4.ucsd.edu!swrinde!gatech!howland.reston.ans.net!torn!news.bc.net!rover.ucs.ualberta.ca!seymour!dc
From: dc@seymour.ucs.ualberta.ca (David Couture)
Newsgroups: comp.lang.perl
Subject: [BUG; 5.001] READONLY lvalue
Date: 11 Apr 1995 14:19:06 GMT
Organization: Computing and Network Services, U of Alberta, Edmonton, Canada
Lines: 19
Message-ID: <3me34q$f60@rover.ucs.ualberta.ca>
NNTP-Posting-Host: seymour.ucs.ualberta.ca
X-Newsreader: NN version 6.5.0 #4 (NOV)

Perl: 5.001 + patches
OS: NeXT 2.1

The following line fails with "modification of read-only value" message.

vec($array[0], 0, 1) = 1;

Replacing "$array[0]" with "$array" works.

/dc.
---
David Couture "A Briefer History of Time" ... "BANG!"
University of Alberta -- Journal of Irreproducible Results
Edmonton, Alberta Canada
--
---
David Couture "A Briefer History of Time" ... "BANG!"
University of Alberta -- Journal of Irreproducible Results
Edmonton, Alberta Canada




************ History ************
bugs 950411 000000 Submitted to NL.perl by dc@seymour.ucs.ualberta.ca (David Couture)