Topic: Integral promotions on bit-fields
Author: kavdeiv@mail.ru (Kiril Avdeiv)
Date: Thu, 19 Jul 2001 16:09:20 GMT Raw View
I cannot discern the meaning of the statement from the standard saying
that if a bit-field is larger than int or unsigned int, no integral
promotions apply to it. It's in 4.5 par. 3.
Assuming a machine with a size of general-purpose register equal 32
bits (where a byte takes up 8 bits) and a C++ implementation where an
int is 32 bits and a long is 64 bits. And the following snippet of
code:
struct ExternalInterface {
long field1:36, field2:28;
};
int main() {
ExternalInterface myinstance = { 0x100000001L, 0x12,};
if(myinstance.field1 < 0x100000002L) { //do something }
}
Does the standard prohibit the implementation from promoting field1's
value into two general purpose registers? And imposes a with it using
masks or shift operations? What else could that phraze mean?
Either alternative is implementation specific, so I don't understand
why the phraze "If the bit-field is larger yet, no integral promotions
apply to it".
Thanks for any clarification.
Kiril
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: kavdeiv@mail.ru (Kiril Avdeiv)
Date: Thu, 19 Jul 2001 19:00:57 GMT Raw View
{Dear moderators, please disregard the prev. posting of mine under the
same name}
I cannot discern the meaning of the statement from the standard saying
that if a bit-field is larger than int or unsigned int, no integral
promotions apply to it. It's in 4.5 par. 3.
Assuming a machine with a size of general-purpose register equal 32
bits (where a byte takes up 8 bits) and a C++ implementation where an
int is 32 bits and a long is 64 bits. And the following snippet of
code:
struct ExternalInterface {
long field1:36, field2:28;
};
int main() {
ExternalInterface myinstance = { 0x100000001L, 0x12,};
if(myinstance.field1 < 0x100000002L) { //do something }
}
Does the standard prohibit the implementation from promoting field1's
value into two general purpose registers? And imposes a burden of
using shift operations to work with the field's value? What else could
that phraze mean?
Either alternative is implementation specific, so I don't understand
why the phraze "If the bit-field is larger yet, no integral promotions
apply to it" made it to the standard.
Thanks for any clarification.
Kiril
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]