How to determine the bit order allocation at compile time?
<p>as we all known, for some compilers:</p>

<pre><code>struct T{
    char bits: 4; // 3:0
};
</code></pre>

<p>and for others:</p>

<pre><code>struct T{
    char bits: 4; // 7:4
};
</code></pre>

<p>since this is not specified by the standard. ( I do think this (the arithmetic meaning) should be specified by the standard, and the actual physical allocation is another issue that can't be specified. )</p>

<p>However, I want my code to be more generic, so I tried:</p>

<pre><code>union helper{
    unsigned char b:1;
    unsigned char c;
    constexpr helper(unsigned char i): c(i){}
};

constexpr int lsb_defined_at_top(){ return helper(1).b;}

enum{
    LSB_AT_DEFINED_AT_TOP = lsb_defined_at_top()
};
</code></pre>

<p>but the compiler (gcc 4.7.2) complains:</p>

<p>error: accessing 'helper::b' member instead of initialized 'helper::c' member in constant expression</p>

<p>I wonder is there any way to determine this at compile time ...</p>
