Unions and CTFE
Jimmy Cao via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 18 09:21:39 PST 2015
On Friday, 18 December 2015 at 14:30:25 UTC, Gianni Pisetta wrote:
> Hi all,
> i'm coding a parametrized crc implementation that can support
> most of the standards. I want to make it work with CTFE and i
> stumbled upon a difficulty when using
> std.bitmanip.nativeToLittleEndian and
> std.bitmanip.nativeToBigEndian.
> The code below is the concept used by EndianSwapper and it does
> not compile because of unions and CTFE. Also as the error
> message is very obscure, is it intended behaviour or a bug?
I think it's intended behavior. According to
http://dlang.org/changelog/2.065.0.html#ctfe-overlapped-field
"Bit image reinterpretation by using two overlapped union fields
is not allowed during CTFE."
More information about the Digitalmars-d
mailing list