4 ms·
> Wait, are you saying gcc/clang's behaviour is permitted by the standard, or not? It's permitted. The same way as a char can be signed or unsigned: Implementa
by pksadiq 10y ago
> Wait, are you saying gcc/clang's behaviour is permitted by the standard, or not?
It's permitted. The same way as a char can be signed or unsigned: Implementation defined. But in this case, it's always signed regardless of the architecture (against how a char is handled).
From c99 draft (n1570), J.3.9 (Implementation-defined behavior):
Whether a ‘‘plain’’ int bit-field is treated as a signed int bit-field or as an
unsigned int bit-field (6.7.2, 6.7.2.1).
But say, another compiler (ARM compiler) treats this differently [0]: Untill version 5 of the compiler, such an int was unsigned by default. Later versions defaulted to signed (as do gcc/clang).
[0] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15377.html http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....