This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

main() { double x[1048181]; int n = sizeof(x); }


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]