Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

visual studio - invalid std::string debugger output in Release mode

alt text

There's nothing fancy going on in this program, but I get garbage output. Here are the header files I'm including, in case that's relevant.

#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <vector>
#include <string>
#include <sstream>

And I'm using Visual Studio 2008 on Windows XP.

Note that if I print the string to stdout, it prints "test" perfectly fine.

like image 375
Clark Gaebel Avatar asked Jun 21 '26 09:06

Clark Gaebel


1 Answers

Sometimes the debugger will have trouble picking up proper values if you've compiled in Release mode. The compiler might swap around operations or move values to registers, etc.

like image 141
Mark Ransom Avatar answered Jun 22 '26 22:06

Mark Ransom