C/C++을 하다보면 자기도 모르는 사이에 임시변수를 쓰곤하는데, 대부분 암묵적 형변환에 의해서이다. 이때 발생하는 임시변수는 어디에 만들어지는 것일까? 보통 함수 내 자동 변수들은 프로세스 스택에 만들어지는 것으로 알고 있다. 정말 그런지 알아봐야겠다. #include <iostream> #include <string> using namespace std; volatile bool gTest(true); const char gString[] = "Hello, world!"; template<typename _T> void _func(const _T& v) { cerr << "Temporary variable: " << (void*)&v << endl; cerr << "Temporary buffer: " << (void*)(v.c_str()) << endl; } template<typename _T> void callStack(void) { _T local1; cerr << "Type ID: " << typeid(local1).name() << endl; cerr << "Local1 variable: " << (void*)&local1 << endl; cerr << "Local1 buffer: " << (void*)(local1.c_str()) << endl; if ( gTest ) { _T local2; cerr << "Local2 variable: " << (void*)&local2 ...