Opencv and "OpenCV Error: Bad flag"


   
I had pretty simple code with opencv:

    cv::Mat t;
    t = cv::imread( "qq.bmp" ) ;
    cv::imwrite( "q.bmp", t );
    cv::namedWindow( "asdads", CV_WINDOW_AUTOSIZE );
    cv::imshow( "asdads", t );
    cv::waitKey( -1 );
    return 0;

It caused crash in debug configuration:

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupport
ed array type) in unknown function, file ..\..\..\src\opencv\modules\core\src\ar
ray.cpp, line 2482

In release configuration it was ok. Finally i found the solution. Both in debug and release configurations I used static libraries for release conguration

opencv_core231.lib opencv_imgproc231.lib opencv_highgui231.lib

And one should use
opencv_core231d.lib opencv_imgproc231d.lib opencv_highgui231d.lib
for debug.

It seems wrong libraries cause crashes only sometimes. I had used release version of static opencv libraries for my debu and release configurations for a long time an only now it caused problems