This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
main() { double x[1048181]; int n = sizeof(x); }
- To: gcc-bugs at gcc dot gnu dot org
- Subject: main() { double x[1048181]; int n = sizeof(x); }
- From: Alexander Zvyagin <zvyagin at gams dot ihep dot su>
- Date: Wed, 5 Jan 2000 22:10:07 +0300 (MSK)
Dear GCC developers,
to my great surprise this code
main() { double x[1048181]; int n = sizeof(x); }
cause "Segmentation fault" under gcc-2.95.2.
$ g++ 2.c
$ a.out
Segmentation fault
$ g++ -O1 2.c
$ a.out
There is no "seg.fault" if optimisation is ON!
This is difference in assembler code:
$ diff 2bad.s 2good.s
14c14
< subl $8385464,%esp
---
> subl $8385448,%esp
There are not any problems if value 1048180 (or smaller) is used.
So 1048181 (and bigger) is, hmm..., magic number.
With best wishes,
Alexander Zvyagin.