April 14, 2006 [bug] dmc.8.48.3 bit fields for 64-bit integer | ||||
---|---|---|---|---|
| ||||
Code below produces incorrect output (seems that code generator makes invalid code, since nothing is changed when compiling with -o-all): a.pos = A; b.pos = 1234567890A; But clearly, these values should be identical; Due to this bug I can't use bitfields for int64 in structure. Nic Tiger. dmc int64_bug.cpp ---------------------- #include <stdio.h> #include <stdint.h> struct A { uint64_t pos: 36; }; struct B { uint64_t pos; }; int main() { A a; B b; a.pos = 0x1234567890A; b.pos = 0x1234567890A; printf ( "a.pos=%llX\n", a.pos ); printf ( "b.pos=%llX\n", b.pos ); return 0; } |
April 14, 2006 Re: [bug] dmc.8.48.3 bit fields for 64-bit integer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nic Tiger | Nic Tiger wrote:
> Code below produces incorrect output (seems that code generator makes invalid code, since nothing is changed when compiling with -o-all):
> a.pos = A;
> b.pos = 1234567890A;
> But clearly, these values should be identical; Due to this bug I can't use bitfields for int64 in structure.
ugh....
just came across "9.6-1 Bit Fields" section in DMC C++ language implementation / Implementation-defined Behavior.
so, bit fields larger than 32 bit (word size) are not allowed.
though, it would be nice if compiler emitted error about that...
Nic Tiger.
|
Copyright © 1999-2021 by the D Language Foundation