I was trying to determine the largest possible value in a bit field, what I did is:
using namespace std;
struct A{
unsigned int a:1;
unsigned int b:3;
};
int main()
{
A aa;
aa.b = ~0U;
return 0;
}
MSVC is fine but GCC 4.9.2 gave me a warning:
warning: large integer implicitly truncated to unsigned type [-Woverflow]
Wondering how I can get rid of it (Assuming I don't know the bit width of the field, and I want to know what's the largest possible value in it).