This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66603] using std::cout causes segfault with unrelated array declaration
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Jun 2015 20:16:10 +0000
- Subject: [Bug c++/66603] using std::cout causes segfault with unrelated array declaration
- Auto-submitted: auto-generated
- References: <bug-66603-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66603
--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
Another detail that might confuse you: if you write
in n=4000000;
int a[n];
it will probably not crash. The reason is that variables like 'int a[4000000]'
exist for the whole length of the function, the memory for them is reserved at
function entry, so the stream operation happens after the memory was reserved.
On the other hand, a dynamic allocation (VLA) happens at the point where it is
requested, i.e. after the stream op, and there is no operation afterwards to
use the stack and crash the program.