Io 为什么下面的C++;在发布模式下出现错误但在调试模式下工作正常的代码?

Io 为什么下面的C++;在发布模式下出现错误但在调试模式下工作正常的代码?,io,visual-studio-2017,Io,Visual Studio 2017,我试图从一个文件中读取2个整数,并将其总和写入另一个文件。在发布模式下运行以下代码(Visual Studio 2017社区) 在修改代码时,我发现注释掉cout行(有一个“LineinQuestion”注释)可以使代码正常运行。我最初的怀疑是,由于这两个变量是写入标准输出流的,所以它们不能写入标准输出流。然而,当我注释掉“fout”时,如果你问我的话,它看起来像一个编译器错误。..@EugeneSh。很抱歉问你这个问题,我能做点什么吗?报告吧。然后试着解决这个问题,用一些等效的命令来替换这个有

我试图从一个文件中读取2个整数,并将其总和写入另一个文件。在发布模式下运行以下代码(Visual Studio 2017社区)


在修改代码时,我发现注释掉cout行(有一个“LineinQuestion”注释)可以使代码正常运行。我最初的怀疑是,由于这两个变量是写入标准输出流的,所以它们不能写入标准输出流。然而,当我注释掉“fout”时,如果你问我的话,它看起来像一个编译器错误。..@EugeneSh。很抱歉问你这个问题,我能做点什么吗?报告吧。然后试着解决这个问题,用一些等效的命令来替换这个有问题的命令。
    // Kickstart.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<string>


int main()
{
    using namespace std;
    string inpath = "E:\\Pratik\\Kickstart\\Inputs\\Sum.txt";
    string outpath = "E:\\Pratik\\Kickstart\\Outputs\\Sum.txt";
    ifstream fin;
    ofstream fout;
    fin.open(inpath);
    fout.open(outpath);
    if (!fin)
    {
        cerr << "Unable to open input file";
        exit(1);
    }
    if (!fout)
    {
        cerr << "Unable to open output file";
        exit(1);
    }
    int sum = 0;
    int a, b;
    fin >> a >> b;
    cout << "a: " << a << "b: " << b << endl; //Line in question
    fout << a + b;
    fin.close();
    fout.close();
    system("pause");
    return 0;
}
1>------ Build started: Project: Kickstart, Configuration: Release x64 ------
1>Kickstart.cpp
1>Generating code
1>LINK : fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 258)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1>  link!InvokeCompilerPass()+0x1f1b9
1>  link!InvokeCompilerPass()+0x1f1b9
1>  link!InvokeCompilerPass()+0x1ebd3
1>  link!DllGetC2Telemetry()+0x10769b
1>
1>LINK : fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 258)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1>  link!InvokeCompilerPass()+0x1f1b9
1>  link!InvokeCompilerPass()+0x1ebd3
1>  link!DllGetC2Telemetry()+0x10769b
1>
1>
1>LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
1>
1>  Version 14.12.25831.0
1>
1>  ExceptionCode            = C0000005
1>  ExceptionFlags           = 00000000
1>  ExceptionAddress         = 063636E6 (05F30000) "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\c2.dll"
1>  NumberParameters         = 00000002
1>  ExceptionInformation[ 0] = 00000000
1>  ExceptionInformation[ 1] = 0FA6D358
1>
1>CONTEXT:
1>  Eax    = 0FA6D358  Esp    = 008FE9E8
1>  Ebx    = 05A500EC  Ebp    = 008FEA18
1>  Ecx    = 00000005  Esi    = 0FA6D358
1>  Edx    = 08C8C02C  Edi    = 008FE9F8
1>  Eip    = 063636E6  EFlags = 00010202
1>  SegCs  = 00000023  SegDs  = 0000002B
1>  SegSs  = 0000002B  SegEs  = 0000002B
1>  SegFs  = 00000053  SegGs  = 0000002B
1>  Dr0    = 00000000  Dr3    = 00000000
1>  Dr1    = 00000000  Dr6    = 00000000
1>  Dr2    = 00000000  Dr7    = 00000000
1>Done building project "Kickstart.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========