Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'static': 0.04; 'subject:Python': 0.06; '#include': 0.09; 'arrays': 0.09; 'global,': 0.09; 'here?': 0.09; 'i++)': 0.09; 'lawrence': 0.09; 'main()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'python': 0.11; 'array.': 0.16; 'garbage': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'trusty': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'programming': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'references': 0.26; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; "d'aprano": 0.31; 'gcc': 0.31; 'steven': 0.31; 'subject:end': 0.31; 'skip:_ 10': 0.34; 'no,': 0.35; 'but': 0.35; 'christian': 0.38; 'filled': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'world.': 0.61; 'hang': 0.67; 'believe': 0.68; 'edwards': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Python Front-end to GCC Date: Tue, 22 Oct 2013 17:50:29 +0100 References: <4012031f-5334-4be8-a673-e0d8c8917fb2@googlegroups.com> <5264dbbe$0$30000$c3e8da3$5496439d@news.astraweb.com> <5265bba8$0$29981$c3e8da3$5496439d@news.astraweb.com> <526668e5$0$29981$c3e8da3$5496439d@news.astraweb.com> <52669852$0$29981$c3e8da3$5496439d@news.astraweb.com> <5266aa80$0$29981$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-19-253.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 In-Reply-To: <5266aa80$0$29981$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382460650 news.xs4all.nl 15864 [2001:888:2000:d::a6]:59801 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57273 On 22/10/2013 17:40, Steven D'Aprano wrote: > On Tue, 22 Oct 2013 15:39:42 +0000, Grant Edwards wrote: > >>> No, I was thinking of an array. Arrays aren't automatically initialised >>> in C. >> >> If they are static or global, then _yes_they_are_. They are zeroed. > > Not that I don't believe you, but do you have a reference for this? > Because I keep finding references to uninitialised C arrays filled with > garbage if you don't initialise them. > > Wait... hang on a second... > > /fires up the ol' trusty gcc > > > [steve@ando c]$ cat array_init.c > #include > > int main() > { > int i; > int arr[10]; > for (i = 0; i < 10; i++) { > printf("arr[%d] = %d\n", i, arr[i]); > } > printf("\n"); > return 0; > } > > [steve@ando c]$ gcc array_init.c > [steve@ando c]$ ./a.out > arr[0] = -1082002360 > arr[1] = 134513317 > arr[2] = 2527220 > arr[3] = 2519564 > arr[4] = -1082002312 > arr[5] = 134513753 > arr[6] = 1294213 > arr[7] = -1082002164 > arr[8] = -1082002312 > arr[9] = 2527220 > > > What am I missing here? > > arr is local to main, not static or global. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence