Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: local arrays and stack Date: Wed, 25 Mar 2015 12:50:28 -0700 Organization: None to speak of Lines: 17 Message-ID: <87pp7wq2kb.fsf@kst-u.example.com> References: <87k2y7u48c.fsf@kst-u.example.com> <705a5674-dbc9-460a-a72c-50bf1946be01@googlegroups.com> <87fv8vu1sx.fsf@kst-u.example.com> <1f3963cb-74d2-4b38-9241-fd6ce6c5179c@googlegroups.com> <3f401918-2171-4808-bbdb-c86d7b879d07@googlegroups.com> <46c41165-11a3-4c8e-8097-6747e5177442@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="c77ff4d35e33d1c939d3461ebde8dd0d"; logging-data="27514"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xi8hlSbTL8Z4OT0jyWCyE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:lbdJ+eKOP6fDs7iCs5dDetgLaSU= sha1:Urr5QqDVPquq8PPnmwOzrUzSZZ8= Xref: csiph.com comp.lang.c:58953 Bartc writes: [...] > (In fact, I didn't realise until this thread that VLAs were so > unsafe. You know about the usually remote risks of stack overflow when > some recursive algorithm goes out of control, but with VLAs you don't > even need to call one function, just declaring an array in the middle > of main() could be enough to bring down an application!) Just declaring a fixed-size array in the middle of main() could do exactly the same thing. The only thing VLAs add is the ability to determine the size at run time. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"