When I want to release the memory of the vector of the member variable by swap, it is always crash, and the breakpoint goes in the crash position is also very strange:
Crash Location:
I thought it was an issue with memory misalignment, and the result was added
#pragma pack (4) //1, 2, 4
Also in vain ... t_t
Automatic release of vector for local variables Crash position:
And the same code is normal on OpenCV 3.1.0.
Strange I was almost suspicious of people Sen when, finally God let me find this article.
See the last sentence, only to recall that their own OpenCV2.4.12 is compiled by VS2012 (originally Opencv+cuda, found that the highest support only VS2013, and I on the machine except VS2015 is VS2012, so VS2012 is set as the default CMake compiler), and its own default development IDE is VS2015, which leads to such a bizarre problem ... (This is also the reason why a similar cout will crash when printing the Mat)
Record only to prevent recidivism
Attached: Accidental Harvest