title: Visual studio stack overflow when defining variables (c++)
body: <p>I've been trying to solve a competition problem in the style of the link below using c++ (the actual problem that I'm trying to solve isn't available for the public)</p>
  
  <p><a href="http://orac.amt.edu.au/cgi-bin/train/problem.pl?set=aio18int&amp;problemid=1032" rel="nofollow noreferrer">http://orac.amt.edu.au/cgi-bin/train/problem.pl?set=aio18int&amp;problemid=1032</a></p>
  
  <p>I have written a C++ program in Visual studio that attempts to solve it, but when I run this code: (there are some includes for  and  but I couldn't get the formatting).</p>
  
  <pre><code>    int main() 
  {
  int n = 1;
  
  freopen("pairin.txt", "r", stdin);
  
  
  scanf("%d", &amp;n);
  
  int s[200005];
  for (int i = 0; i &lt; 2 * n; i++)
  {
      scanf("%d", &amp;s[i]);
  }
  
  int d[100005];
  for (int i = 0; i &lt; n; i++) {
      d[i] = -1;
  }
  
  for (int i = 0; i &lt; n; i++) {
      if (d[s[i] - 1] == -1) {
          d[i] == s[i];
      }
      else {
          d[i] = i - d[i];
      }
  }
  
  int max = 0;
  for (int i = 0; i &lt; n; i++) {
      if (d[i] &gt; max) {
          max = d[i];
      }
  }
  
  freopen("pairout.txt", "w", stdout);
  printf("%d", max);
  
  return 0;
  }
  </code></pre>
  
  <p>It returns the error: 
      Unhandled exception at 0x00B11CC9 in a.exe: 0xC00000FD: Stack overflow            (parameters: 0x00000000, 0x00402000). occurred</p>
  
  <p>Visual studio then opens up a tab of an asm file called chkstk.asm for whatever reason.</p>
  
  <p>I have an idea of when this error occurs normally, but what seemed to be triggering it was defining "int n = 1;" when I stepped through with the  debugger, which absolutely boggles my mind. All I want to do is debug my algorithm, not trying to get int n = 1; to work.</p>
  
  <p>I'm using Visual Studio 2017, with  the _CRT_SECURE_NO_WARNINGS flag enabled.</p>
  
  <p>I tried this in an online IDE (commenting out all the IO lines) and main() returned 0 just fine.</p>