Hi,
I just had a bug due to the unitentional usage of the comma operator. So
I'm wondering if there could something be done so that the compiler
prevents something like this:
memStart = cast(T*)(m_allocator.AllocateMemory(size * T.sizeof),
InitializeMemoryWith.NOTHING);
This first excutes AllocateMemory, then throws away the result and then
casts the enum InitializeMemory.NOTHING value to a pointer, which will
always result in a null pointer. This took me quite some time to spot.
What I actually wanted to do:
memStart = cast(T*)(m_allocator.AllocateMemory(size * T.sizeof,
InitializeMemoryWith.NOTHING));
1) So is it actually neccessary that enums can be casted directly to
pointers?
2) Is the functionality provided by the comma operator actually worth
the bugs it causes?
Kind Regards
Benjamin Thaut