All pastes #740015 Raw Edit

Mine

public text v1 · immutable
·published 2007-10-17 17:09 UTC
rendered paste body
union
	{
		int a;
		struct 
		{
			unsigned _0 :1;
			unsigned _1 :1;
			unsigned _2 :1;
			unsigned _3 :1;
			unsigned _4 :1;
			unsigned _5 :1;
			unsigned _6 :1;
			unsigned _7 :1;
			unsigned _8 :1;
			unsigned _9 :1;
			unsigned _10 :1;
		} bits;
	} t;
	void* p = &t.a;
	unsigned us = reinterpret_cast<unsigned>(p);
	us ++;
	p = reinterpret_cast<void*>(us);
	t.bits._0 = 0;
	t.bits._1 = 0;
	t.bits._2 = 0;
	t.bits._3 = 0;
	t.bits._4 = 0;
	t.bits._5 = 0;
	t.bits._6 = 0;
	t.bits._7 = 0;
	t.bits._8 = 0;
	t.bits._9 = 0;
	t.bits._10 = 0;
	char& val = *(char*)(p);
	char old_val = val;
	int j = 0;
	bool found = false;
	t.bits._0 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._1 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._2 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._3 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._4 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._5 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._6 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._7 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._8 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._9 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;
	t.bits._10 = 1; if ((!found) && (val != old_val)) { std::cout<< j <<" bits" <<std::endl; found = true;} ++j;