[Issue 22710] New: Different behaviour of bitfields between CTFE and runtime
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 28 19:15:55 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22710
Issue ID: 22710
Summary: Different behaviour of bitfields between CTFE and
runtime
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
The CTFE engine ins't aware of the subtle differences of bitfields vs normal
variables. This manifests e.g. in incorrect overflow behaviour:
--- app.d
import bitfields;
extern(C) int main()
{
HasBitfield bf;
bf.a += 4;
assert(bf.a == 0); // Fails during CTFE
assert(bf.b == 0);
return 0;
}
enum test = main();
--- bitfields.c
struct HasBitfield
{
int a : 2;
int b : 2;
};
--
More information about the Digitalmars-d-bugs
mailing list