fork(1) download
#include <iostream>

void test(const char* p)
{
	char c = *p;		// 1
	std::cout << p << std::endl;
}

template <typename T>
void test_tmp(T&& x)
{
	auto aa = (T&&)x;					//追加 1 <= これでアクセス違反
	auto bb = static_cast<T&&>(x);		//追加 2 <= OK
	test(x);			// 2
	test((T&&)x);		// 3
}


int main() {
	typedef const char*  const_char_p;
	test("NHK");					// 4
	test((const_char_p&&)"JCB");	// 5
	test_tmp("JiNS");				// 6
	// VC だと 6 => 3 => 1 の呼び出しでアクセス違反終了
	return 0;
}
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
NHK
JCB
JiNS
JiNS