Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
deadalnix
deadalnix at gmail.com
Sun May 19 18:34:39 PDT 2013
On Monday, 20 May 2013 at 01:08:16 UTC, Walter Bright wrote:
> 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.
I cannot agree more. This is what made tracking the cause of the
bug super hard.
> 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.
I didn't programed Apache Cayenne, int he first place. But I had
to patch it anyway.
More information about the Digitalmars-d
mailing list