Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

Walter Bright newshound2 at digitalmars.com
Sun May 19 18:08:15 PDT 2013


On 5/19/2013 5:28 PM, deadalnix wrote:
> The error lie in improper
> initialization of p in the first place, which should never has been null. The
> example looks dumb as this, you have to imagine the pattern hidden in thousands
> of LOC.

I would find a design that declared a variable in one place, then initialized it 
in another, while releasing the lock in between as a bad design pattern to begin 
with. What other default initialized types could be there? What about an int 
default initialized to 0, yet code in another thread expects it to be some other 
value? I suspect there'd be a lot more bugs in it than just null pointer 
initializations.

It might be time to engineer a new pattern so you don't have to inspect 
thousands of LOC to manually verify correctness.


More information about the Digitalmars-d mailing list