1*e6d6c189SCody Peter Mello#From gregfjohnson@yahoo.com Sun Aug 30 08:36:36 2009 2*e6d6c189SCody Peter Mello#Return-Path: <gregfjohnson@yahoo.com> 3*e6d6c189SCody Peter Mello#Received: from aahz (localhost [127.0.0.1]) 4*e6d6c189SCody Peter Mello# by skeeve.com (8.14.1/8.14.1) with ESMTP id n7U5WoJ2003836 5*e6d6c189SCody Peter Mello# for <arnold@localhost>; Sun, 30 Aug 2009 08:36:36 +0300 6*e6d6c189SCody Peter Mello#X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on server1.f7.net 7*e6d6c189SCody Peter Mello#X-Spam-Level: 8*e6d6c189SCody Peter Mello#X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED 9*e6d6c189SCody Peter Mello# autolearn=ham version=3.2.4 10*e6d6c189SCody Peter Mello#X-Envelope-From: gregfjohnson@yahoo.com 11*e6d6c189SCody Peter Mello#X-Envelope-To: <arnold@skeeve.com> 12*e6d6c189SCody Peter Mello#Received: from server1.f7.net [64.34.169.74] 13*e6d6c189SCody Peter Mello# by aahz with IMAP (fetchmail-6.3.7) 14*e6d6c189SCody Peter Mello# for <arnold@localhost> (single-drop); Sun, 30 Aug 2009 08:36:36 +0300 (IDT) 15*e6d6c189SCody Peter Mello#Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) 16*e6d6c189SCody Peter Mello# by f7.net (8.11.7-20030920/8.11.7) with ESMTP id n7U33m709453 17*e6d6c189SCody Peter Mello# for <arnold@skeeve.com>; Sat, 29 Aug 2009 22:03:48 -0500 18*e6d6c189SCody Peter Mello#Received: from mail.gnu.org ([199.232.76.166]:42095 helo=mx10.gnu.org) 19*e6d6c189SCody Peter Mello# by fencepost.gnu.org with esmtp (Exim 4.67) 20*e6d6c189SCody Peter Mello# (envelope-from <gregfjohnson@yahoo.com>) 21*e6d6c189SCody Peter Mello# id 1Mhai6-0004Qt-3R 22*e6d6c189SCody Peter Mello# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:06 -0400 23*e6d6c189SCody Peter Mello#Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) 24*e6d6c189SCody Peter Mello# (envelope-from <gregfjohnson@yahoo.com>) 25*e6d6c189SCody Peter Mello# id 1Mhai5-00062I-EM 26*e6d6c189SCody Peter Mello# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:05 -0400 27*e6d6c189SCody Peter Mello#Received: from web33507.mail.mud.yahoo.com ([68.142.206.156]:28597) 28*e6d6c189SCody Peter Mello# by monty-python.gnu.org with smtp (Exim 4.60) 29*e6d6c189SCody Peter Mello# (envelope-from <gregfjohnson@yahoo.com>) 30*e6d6c189SCody Peter Mello# id 1Mhai5-00061w-2n 31*e6d6c189SCody Peter Mello# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:05 -0400 32*e6d6c189SCody Peter Mello#Received: (qmail 68722 invoked by uid 60001); 30 Aug 2009 03:04:03 -0000 33*e6d6c189SCody Peter Mello#DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1251601443; bh=9h2ZOOgxUh+s8Ow5/ZMWUxcviy2L4rpiaNamPAXxhEk=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=tWxCQq/aTOT5lhtdPc5hxtXzOjDFmLU6Ao0BSlwbeeBsd9Wl6DU3JCR4gTkoL0aVUOTdjMjgRY7I72yCht+YruDiqZrvtSKvUoAvZAKcPG26RE4jzxUlxQklEHZG9mq9h2gpTIiLYehYDiC0975wukwi/e7ePADfkFwg8eTnT44= 34*e6d6c189SCody Peter Mello#DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; 35*e6d6c189SCody Peter Mello# s=s1024; d=yahoo.com; 36*e6d6c189SCody Peter Mello# h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; 37*e6d6c189SCody Peter Mello# b=LWfhVgxojFG1eYoRrxtrS3YOfH3MTUVTYZle/4utMQEPZQfsmrn6GBwBfThryGqJyZfg38/7JfK9cz/Q3Yt+mf8+xl9/m+Srckc+Xvi42CE0OmoN439vCyhAD8A74XOJsmfKDjJ/+LtioShStUohj1iYDDmRTN4RnnP9X4xnt3c=; 38*e6d6c189SCody Peter Mello#Message-ID: <410222.68490.qm@web33507.mail.mud.yahoo.com> 39*e6d6c189SCody Peter Mello#X-YMail-OSG: mfjax.MVM1lI2q5gcl6bChbn6zHgNgj1fByHWJSzB8ZZUmI2QCH6pNwV_IaHxcqecu.VqjKUR6HQhXbziUnX.v5E2nOE61ass9AzqfdVOtKTEAzTPQJ8Z7QB7fq7BMtjn8yohDR6mwOyVTqv3RZh0m1Us7sLit6UmcgeSvJo2rROAmeceq.FBwk2XnEp2_QsljjPHak_WXyvtAK81klDv5qQORWQWqR9q79x7yxORL6fLWwb_x6mZZMSOUaA0p8.ucT453eqT1L8NGkthF.fXmOM3_EYd03zUgr9Sb.zvMvbDC3MCMnVr0JT1uroLmFtVIdTojrFJYFQEDFSB9zT3Ua80ZpGXrjQGx3rZw-- 40*e6d6c189SCody Peter Mello#Received: from [71.165.246.171] by web33507.mail.mud.yahoo.com via HTTP; Sat, 29 Aug 2009 20:04:03 PDT 41*e6d6c189SCody Peter Mello#X-Mailer: YahooMailClassic/6.1.2 YahooMailWebService/0.7.338.2 42*e6d6c189SCody Peter Mello#Date: Sat, 29 Aug 2009 20:04:03 -0700 (PDT) 43*e6d6c189SCody Peter Mello#From: Greg Johnson <gregfjohnson@yahoo.com> 44*e6d6c189SCody Peter Mello#Subject: bugs in passing uninitialized array to a function 45*e6d6c189SCody Peter Mello#To: bug-gawk@gnu.org 46*e6d6c189SCody Peter Mello#MIME-Version: 1.0 47*e6d6c189SCody Peter Mello#Content-Type: multipart/mixed; boundary="0-1690489838-1251601443=:68490" 48*e6d6c189SCody Peter Mello#X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) 49*e6d6c189SCody Peter Mello#Status: RO 50*e6d6c189SCody Peter Mello# 51*e6d6c189SCody Peter Mello#--0-1690489838-1251601443=:68490 52*e6d6c189SCody Peter Mello#Content-Type: text/plain; charset=us-ascii 53*e6d6c189SCody Peter Mello# 54*e6d6c189SCody Peter Mello#I am using gawk version 3.1.7. 55*e6d6c189SCody Peter Mello# 56*e6d6c189SCody Peter Mello#The attached programs illustrate what look to me like two bugs 57*e6d6c189SCody Peter Mello#in the handling of uninitialized variables to functions that treat 58*e6d6c189SCody Peter Mello#them as arrays. 59*e6d6c189SCody Peter Mello# 60*e6d6c189SCody Peter Mello#Greg Johnson 61*e6d6c189SCody Peter Mello# 62*e6d6c189SCody Peter Mello# 63*e6d6c189SCody Peter Mello# 64*e6d6c189SCody Peter Mello#--0-1690489838-1251601443=:68490 65*e6d6c189SCody Peter Mello#Content-Type: application/octet-stream; name=b1 66*e6d6c189SCody Peter Mello#Content-Transfer-Encoding: base64 67*e6d6c189SCody Peter Mello#Content-Disposition: attachment; filename="b1" 68*e6d6c189SCody Peter Mello 69*e6d6c189SCody Peter Mello# bug? on uninitialized array, length(a) prints as 3, then the loop 70*e6d6c189SCody Peter Mello# behaves differently, iterating once. so, length() behaves differently 71*e6d6c189SCody Peter Mello# on two calls to the same variable, which was not changed. 72*e6d6c189SCody Peter Mello 73*e6d6c189SCody Peter Mellofunction prt1(a, len) 74*e6d6c189SCody Peter Mello{ 75*e6d6c189SCody Peter Mello print "length: " length(a) 76*e6d6c189SCody Peter Mello 77*e6d6c189SCody Peter Mello for (i = 1; i <= length(a); i++) 78*e6d6c189SCody Peter Mello printf "<" i "," a[i] "> " 79*e6d6c189SCody Peter Mello 80*e6d6c189SCody Peter Mello print "\n" 81*e6d6c189SCody Peter Mello} 82*e6d6c189SCody Peter Mello 83*e6d6c189SCody Peter MelloBEGIN { 84*e6d6c189SCody Peter Mello prt1(zzz) 85*e6d6c189SCody Peter Mello} 86*e6d6c189SCody Peter Mello 87*e6d6c189SCody Peter Mello#--0-1690489838-1251601443=:68490 88*e6d6c189SCody Peter Mello#Content-Type: application/octet-stream; name=b2 89*e6d6c189SCody Peter Mello#Content-Transfer-Encoding: base64 90*e6d6c189SCody Peter Mello#Content-Disposition: attachment; filename="b2" 91*e6d6c189SCody Peter Mello 92*e6d6c189SCody Peter Mello# shouldn't an uninitialized array have length zero? 93*e6d6c189SCody Peter Mello# length is printed as 1, and the loop iterates once. 94*e6d6c189SCody Peter Mello 95*e6d6c189SCody Peter Mellofunction prt(a, len) 96*e6d6c189SCody Peter Mello{ 97*e6d6c189SCody Peter Mello len = length(a) 98*e6d6c189SCody Peter Mello print "length: " len 99*e6d6c189SCody Peter Mello 100*e6d6c189SCody Peter Mello for (i = 1; i <= len; i++) 101*e6d6c189SCody Peter Mello printf "<" i "," a[i] "> " 102*e6d6c189SCody Peter Mello 103*e6d6c189SCody Peter Mello print "\n" 104*e6d6c189SCody Peter Mello} 105*e6d6c189SCody Peter Mello 106*e6d6c189SCody Peter MelloBEGIN { 107*e6d6c189SCody Peter Mello prt(zzz) 108*e6d6c189SCody Peter Mello} 109*e6d6c189SCody Peter Mello 110*e6d6c189SCody Peter Mello#--0-1690489838-1251601443=:68490-- 111*e6d6c189SCody Peter Mello 112