Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22113

GCC stackoverflow on large array declaration

$
0
0

Below Code works fine

#include "bits/stdc++.h"#define ll long long#define endLine "\n"using namespace std;bool dryRun = true;int main() {    ll n, testCount;    ll arr[100000];    ll pre[100000];    // ll pred[100000];    cin >> testCount;    while (testCount--) {        cin >> n;        cout << n;    }    return 0;}

But Adding a new array gives me stack over flow. Following code doesn't work.

#include "bits/stdc++.h"#define ll long long#define endLine "\n"using namespace std;bool dryRun = true;int32_t main() {    ll n, testCount;    ll arr[100000];    ll pre[100000];    ll pred[100000];    cin >> testCount;    while (testCount--) {        cin >> n;        cout << n;    }    return 0;}

Error I get on above code:

Exception: STATUS_STACK_OVERFLOW at rip=00100401566rax=0000000000052228 rbx=00000000FFFFCC70 rcx=00000000FFE03C18rdx=00000000FFFFCC70 rsi=0000000180294A00 rdi=00000000FFFFCDF0r8 =0000000800038720 r9 =0000000000000000 r10=0000000000000040r11=0000000000000000 r12=0000000000000000 r13=0000000000000000r14=0000000000000000 r15=0000000000000000rbp=00000000FFFFCCD0 rsp=00000000FFFFCC00program=C:\Users\Sahitya\CLionProjects\Codeazon\cmake-build-debug\INCRDEC.exe, pid 1229, thread cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002BStack trace:Frame        Function    Args000FFFFCCD0  00100401566 (0010040108C, 000FFFFCC70, 000FFFFCCD0, 0018004A826)000FFFFCCD0  0000024A228 (000FFFFCC70, 000FFFFCCD0, 0018004A826, 00000000000)000FFFFCCD0  00000000001 (000FFFFCCD0, 0018004A826, 00000000000, 00000000020)000FFFFCCD0  0010040108C (00000000020, FF0700010302FF00, 0018004A7BA, 00180049800)000FFFFCCD0  0018004A826 (00000000000, 00000000000, 00000000000, 00000000000)00000000000  00180048353 (00000000000, 00000000000, 00000000000, 00000000000)000FFFFFFF0  00180048404 (00000000000, 00000000000, 00000000000, 00000000000)End of stack trace

I am trying to run this on a windows machine. Tried this using Cygwin and MinGW both. No Luck.When declaring two arrays of 100000 each of type long long int, I am reserving :(100000 + 100000) * 8 byte => 1600000 bytes => 1600KB => 1.6MB (working).On declaring one more array :(100000 + 100000 + 100000) * 8 byte => 2400000 bytes => 2400KB => 2.4MB (not working).

Tried this on online IDEs, and both snippets are working fine. So probably this is an environment issue.


Viewing all articles
Browse latest Browse all 22113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>