title: Visual studio 2017 - error MSB6006: "CL.exe" exited with code 2
body: <p>Building a project with Visual Studio 2017 i came across this error:</p>
  <blockquote>
  <p>error MSB6006: &quot;CL.exe&quot; exited with code 2.</p>
  </blockquote>
  <p>here is my code:</p>
  <pre><code>int main()
  {
      const int WIDTH=800;
      const int HEIGHT=600;
  
      Bitmap bitmap(WIDTH, HEIGHT);
  
      unique_ptr&lt;int[]&gt; histogram(new int[Mandelbrot::MAX_ITERATIONS + 1]{ 0 });
  
      unique_ptr&lt;int[]&gt; fractal(new int[WIDTH*HEIGHT]{ 0 });
      //int fractal[WIDTH*HEIGHT]{ 0 };
  
      for (int y = 0; y &lt; HEIGHT; y++) {
          for (int x = 0; x &lt; WIDTH; x++) {
              double xFractal = (x - WIDTH / 2 - 200)*2.0 / HEIGHT;
              double yFractal = (y - HEIGHT / 2)*2.0 / HEIGHT;
  
              int iterations = Mandelbrot::getIterations(xFractal, yFractal);
              if (iterations != Mandelbrot::MAX_ITERATIONS) {
                  histogram[iterations]++;
              }
              fractal[y*WIDTH + x] = iterations;
              uint8_t color = 256 * (double)iterations / Mandelbrot::MAX_ITERATIONS;
              color = color*color*color;
              bitmap.setPixels(x, y, color, color, color);
          }
      }
  
      bitmap.write(&quot;Mandelbrot.bmp&quot;);
      return 0;
  }
  </code></pre>
  <p>the problem seems to be the declaration of the fractal array:</p>
  <pre><code>unique_ptr&lt;int[]&gt; fractal(new int[WIDTH*HEIGHT]{ 0 });
  </code></pre>
  <p>if i comment that (and the other lines with the fractal variable) the code compiles just fine, and if i change the unique pointer into a normal int array the code compiles but it throws an exception when i debug it, signaling a stack overflow.</p>
  <p>Reducing the size of the array solves the problem, so it looks like the program doesn't have enough memory space to run. I googled quite a lot and found that visual studio limits the stack size to 1MB by deafult (i might be wrong on that), but i can't find how to increase it manually in visual studio 2017. Can someone help me?</p>
  <p>EDIT: here is the complete output:</p>
  <blockquote>
  <p>1&gt;------ Build started: Project: Fractal, Configuration: Debug Win32 ------</p>
  <p>1&gt;Main.cpp 1&gt;INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual</p>
  <p>Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\CL.exe'</p>
  <p>1&gt;    Please choose the Technical Support command on the Visual C++ 1&gt;</p>
  <p>Help menu, or open the Technical Support help file for more</p>
  <p>information 1&gt;C:\Program Files (x86)\Microsoft Visual</p>
  <p>Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(360,5):</p>
  <p>error MSB6006: &quot;CL.exe&quot; exited with code 2. 1&gt;Done building project</p>
  <p>&quot;Fractal.vcxproj&quot; -- FAILED.</p>
  <p>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p>
  </blockquote>