From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,a191e211a3e9da1d X-Google-Attributes: gid111c93,public X-Google-ArrivalTime: 2001-06-29 14:07:45 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-feeds.jump.net!uunet!dfw.uu.net!diamond.waii.com!not-for-mail From: Art Haas Newsgroups: comp.os.linux.alpha Subject: Re: 13 line c program segfaults on alpha/linux, but not intel. why? Date: 29 Jun 2001 15:59:55 -0500 Organization: Western Geophysical, Houston, TX Message-ID: References: <2M1%6.147007$Bz6.91285@sjc-read.news.verio.net> <9hidff$6la@taumsauk.cs.wustl.edu> NNTP-Posting-Host: haasart1.dhcp.wg.waii.com X-Trace: mail1.wg.waii.com 993848415 27118 137.144.12.74 (29 Jun 2001 21:00:15 GMT) X-Complaints-To: usenet@news.wg.waii.com NNTP-Posting-Date: 29 Jun 2001 21:00:15 GMT X-Newsreader: Gnus v5.7/Emacs 20.5 Xref: archiver1.google.com comp.os.linux.alpha:3212 berkley@taumsauk.cs.wustl.edu (Berkley Shands) writes: > you have overrun the static storage limit for arrays... > > #include #include > #define SIZE 1047977 > > main () > { > /* double vector_x [SIZE]; */ > double *vector_x = NULL; > int x = 0; > > vector_x = (double *) malloc(sizeof(double) * (SIZE + 1)); vector_x = malloc(sizeof(double) * (SIZE + 1)); > if (! vector_x) > { > perror("malloc failed"); > exit(-1); > } > for ( x = 0; x < SIZE; x++ ) > vector_x [x] = (double) x; > > printf ("\n x [%d] = %.4lf\n\n", SIZE - 1, vector_x [SIZE - 1] ); > } > > (Xp1000 512mb 500mhz ev6 redhat 7.0 running 2.4.5) > > Xp1000@alleycat /tmp> cc test.c > test.c: In function `main': > test.c:10: warning: cast to pointer from integer of different size > Xp1000@alleycat /tmp> a.out > [ ... snip ... ] You need to `#include ' for the prototype for malloc(), and you don't need the cast. I think the changes above should rid you of the warnings generated by the compiler, too. -- ############################### # Art Haas # (713) 689-2417 ###############################