* memory
@ 2002-10-13 17:54 esg
2002-10-14 4:06 ` memory Claudio Bley
2002-10-14 4:51 ` memory Eljay Love-Jensen
0 siblings, 2 replies; 3+ messages in thread
From: esg @ 2002-10-13 17:54 UTC (permalink / raw)
To: gcc-help
Declaring char a[15000000] gives me segmentation fault with g++
(on RedHat 7.1). Any suggestions?
Thanks
Josef Eschgfaeller
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: memory
2002-10-13 17:54 memory esg
@ 2002-10-14 4:06 ` Claudio Bley
2002-10-14 4:51 ` memory Eljay Love-Jensen
1 sibling, 0 replies; 3+ messages in thread
From: Claudio Bley @ 2002-10-14 4:06 UTC (permalink / raw)
To: esg; +Cc: gcc-help
>>>>> "Josef" == <esg@unife.it> writes:
Josef> Declaring char a[15000000] gives me segmentation fault with
Josef> g++ (on RedHat 7.1). Any suggestions?
Well, the default compiler on RH 7.1 is gcc 2.96 which is just an old
development snapshot, was never intended to be released, is probably a
"bit" buggy at best and most importantly not supported in any way from
the GCC folks.
I hear, RH 8.0 is avialable and maybe it's a good time to upgrade your
distribution and compiler NOW.
Btw, the following works for me using GCC 3.2:
char a[15000000];
int main ()
{
a[1] = 'a';
a[2] = 'b';
}
--
Claudio Bley ASCII ribbon campaign (")
Debian GNU/Linux advocate - against HTML email X
http://www.cs.uni-magdeburg.de/~bley/ & vCards / \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: memory
2002-10-13 17:54 memory esg
2002-10-14 4:06 ` memory Claudio Bley
@ 2002-10-14 4:51 ` Eljay Love-Jensen
1 sibling, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2002-10-14 4:51 UTC (permalink / raw)
To: esg, gcc-help
Hi Josef,
>> Declaring char a[15000000] gives me segmentation fault with g++ (on
RedHat 7.1). Any suggestions?
Your stack isn't big enough. Make your stack larger when you compile/run
your program.
Alternatively, declare your char a[15000000] variable on the heap via
"char* a = new char[15000000];", remember to manage the memory with a
"delete[] a". Better yet, use a "vector<char> a(15000000, '\0');", which
will manage the memory for you.
--Eljay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-10-14 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13 17:54 memory esg
2002-10-14 4:06 ` memory Claudio Bley
2002-10-14 4:51 ` memory Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).