Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

crash because of double f[1000000]

basti_b
2014-05-22
2014-05-24
  • basti_b
    basti_b
    2014-05-22

    Hi,

    I try to use a large double array, but here seems to be some overflow if I make it too large:

    #include <stdio.h>
    int main()
    {
        double f[1000000];       // produces crash
        double g[100000];        // works fine    
    }
    

    What's my problem? Is this supposed to be like that and if so, how can I use larger arrays?

    Thanks,
    basti_b


    Windows 7, Dev-C++ 5.4.0, TDM-GCC 4.7.1 64-bit

    Edit: added system information, changed 2nd array name to avoid misunderstandings

     
    Last edit: basti_b 2014-05-24
    • szczurek
      szczurek
      2014-05-22

      Propably you've declared the same name of array f ?

      2014-05-22 12:44 GMT+02:00 basti_b der_ich@users.sf.net:

      Hi,

      I try to use a large double array, but here seems to be some overflow if I
      make it too large:

      include <stdio.h>int main(){

      double f[1000000];       // produces crash
      double f[100000];        // works fine    }
      

      What's my problem? Is this supposed to be like that and if so, how can I
      use larger arrays?

      Thanks,
      basti_b


      crash because of double f[1000000]https://sourceforge.net/p/dev-cpp/discussion/48211/thread/013ad280/?limit=50#7aef

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dev-cpp/discussion/48211/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      Attachments
      • basti_b
        basti_b
        2014-05-24

        haha, You're funny...
        No. I just put them together in there to clarify the problem.
        In reality I just added/deleted a 0 in [].

         
  • Merak
    Merak
    2014-05-22

    Answer fetched from stack overflow:

    If you have declared the array in local scope (inside some routine), size limit is determined by stack size. -If gcc is running on linux, the stack size is determined by some environment variable. Use ulimit -a to view and ulimit -s STACK_SIZE to modify the stack size.

    -If gcc is running on windows (like MinGW), stack size can be specified by gcc -Wl,--stack, STACK_SIZE.

    If you have declared the array in global scope, the array is stored in DATA or BSS section (based on whether the array is initialized or uninitialized respectively). The DATA and BSS section size are determined by underlying OS.

    If you have declared the array in static scope (like static int array[SIZE]), again, the array is stored in DATA or BSS section (based on whether the array is initialized or uninitialized respectively). The DATA and BSS section size are determined by underlying OS.

     
    • Bonsignore
      Bonsignore
      2014-05-23

      We spend a lot of time and do lots of efforts to manage such big
      things in computers! You want a flat address space; the bigger, the
      more OS oriented your solution will need be. No one tried to answer my
      question(s)? I am having trouble reading file lists in Windows...

      On 5/22/14, Merak mehrak@users.sf.net wrote:

      Answer fetched from stack overflow:

      If you have declared the array in local scope (inside some routine), size
      limit is determined by stack size. -If gcc is running on linux, the stack
      size is determined by some environment variable. Use ulimit -a to view and
      ulimit -s STACK_SIZE to modify the stack size.

      -If gcc is running on windows (like MinGW), stack size can be specified by
      gcc -Wl,--stack, STACK_SIZE.

      If you have declared the array in global scope, the array is stored in DATA
      or BSS section (based on whether the array is initialized or uninitialized
      respectively). The DATA and BSS section size are determined by underlying
      OS.

      If you have declared the array in static scope (like static int
      array[SIZE]), again, the array is stored in DATA or BSS section (based on
      whether the array is initialized or uninitialized respectively). The DATA
      and BSS section size are determined by underlying OS.


      crash because of double
      f[1000000]


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dev-cpp/discussion/48211/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Danilo J Bonsignore

       
    • basti_b
      basti_b
      2014-05-24

      Ok, I'll try that.
      Windows 7, by the way. Forgot to add it to my original post, I'm going to do that right now.

       
  • Merak
    Merak
    2014-05-23

    I don't understand the reply from Bonsignore?

    You are not the OP and if you don't understand the answer ( and consider it "not trying to answer" ) maybe you should consider something simpler to start with?