코드를 포함하는 프로젝트에는 모든 기본 MSVS2008 설정이 있습니다. 나는 다음과 같은 오류가 (윈도우 7, 비주얼 스튜디오 2008에서)이 실행하려고IncrCalcPtrs 중 내부 오류 - 두 번째 코드를 실행할 때 다시 발생하지 않습니다.
#include <vector>
#include <iostream>
#include <numeric>
using namespace std;
template <class T> void print(const vector<T>& l)
{ // A generic print function for vectors
cout << endl << "PV Size of vector is " << l.size() << "\n[";
for(int i = 0; i < l.size(); i++)
{
cout<<l[i]<<",";
}
cout << "]\n";
}
int main()
{
vector<double> vec1(4, 2.0);
vector<double> vec2(4, 4.0);
double init = 0.0;
double summation = accumulate(vec1.begin(), vec1.end(), init);
cout<<"Summation = "<<summation<<", init is "<<init<<endl;
double ip = inner_product(vec1.begin(), vec1.end(), vec2.begin(), init);
cout<<"ip = "<<ip<<", init is "<<init<<endl;
int size = 6;
int seed_value = 2;
vector<int> vec3(size, seed_value);
vector<int> result(size);
partial_sum(vec3.begin(), vec3.end(), result.begin());
cout<<"The partial sum of vec3 is ";
print(vec3);
int sz = 10;
int value = 2;
vector<int> vec4(sz);
for(int it = 0; it < vec4.size(); it++){
vec4[it] = value;
value++;
}
vector<int> result2(vec4.size());
adjacent_difference(vec4.begin(), vec4.end(), result2.begin());
cout<<"Adjacent differenec of vec4 is ";
print(vec4);
return(0);
}
처음 :
다음 코드는 내가 STL의 다양한 제품과 자신을 익숙하고있는 사용을 고려 :
c:\programming\numeric_algorithms_on_vectors.cpp(86) : warning C4018: '<' : signed/unsigned mismatch
c:\programming\numeric_algorithms_on_vectors.cpp(37) : warning C4018: '<' : signed/unsigned mismatch
c:\programming\numeric_algorithms_on_vectors.cpp(81) : see reference to function template instantiation 'void print(const std::vector<_Ty> &)' being compiled
with
[
_Ty=int
]
Linking...
numeric_algorithms_on_vectors.obj : fatal error LNK1000: Internal error during IncrCalcPtrs
Version 9.00.30729.01
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 00E6B8C0 (00E10000) "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\link.exe"
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 0000001C
CONTEXT:
Eax = 00000000 Esp = 0042EAE8
Ebx = 3FFF0000 Ebp = 0042EB04
Ecx = 77CB36FA Esi = 4000AF9C
Edx = 4000F774 Edi = 00000000
Eip = 00E6B8C0 EFlags = 00010293
SegCs = 00000023 SegDs = 0000002B
SegSs = 0000002B SegEs = 0000002B
SegFs = 00000053 SegGs = 0000002B
Dr0 = 00000000 Dr3 = 00000000
Dr1 = 00000000 Dr6 = 00000000
Dr2 = 00000000 Dr7 = 00000000
는하지만, 내가 무엇이든지 코드를 변경하지 않고 다시 동일한 코드를 디버깅 할 때 내 코드가 제대로/일을 컴파일되지 않았 음을 말해 창문을 통해 클릭 한 후, 프로그램이 작동합니다. 코드가 컴파일/링크/처음 실행되지 않고 다음 번에 완벽하게 실행되는 이유가 있습니까?
"코드를 변경하지 않고 동일한 코드를 다시 디버깅 할 때"- 실제로 ** 정말 확실합니까? 구성 설정 (예 : 경고 수준, 코드 생성 설정, 컴파일러/링커 스위치 등)은 어떻습니까? –
@In Silico : 예 ... 변경 사항 없음 코드/설정에서 WHATSOEVER가 첫 번째 실행과 두 번째 실행 사이에 발생합니다. – Tryer
이 동작을 재현 할 수 있습니까? –