In case you get mysterious crashes, inexplicable messages of access violations and other strange errors on seemingly innocent code:
Check your project settings, especially if your project makes use of other (3rd party) libraries:
Is each of the (sub)projects and/or libraries using the same run-time libraries?
Meaning: Same version, same threading model, same linking model.
Keyword for Visual C++ users: Compiler flags
Are you maybe mixing release and debug build libraries in the same project?
So simple, and yet so easy to overlook and hard to detect.