Re: Detect uninitialized class var access

2022-09-26 Thread wjoe via Digitalmars-d-learn
On Monday, 26 September 2022 at 16:51:11 UTC, rikki cattermole wrote: Currently in D you would be forced to create a vtable struct manually. Or I could just use classes. The cure shouldn't be worse than the disease. But if we had something like signatures you could do this: ```d struct Foo {

Re: Detect uninitialized class var access

2022-09-26 Thread rikki cattermole via Digitalmars-d-learn
Currently in D you would be forced to create a vtable struct manually. But if we had something like signatures you could do this: ```d struct Foo { //... } struct Bar { InputRange input; } void doIt() { Bar bar; Foo* foo = new Foo; bar.input = foo; } ```

Re: Detect uninitialized class var access

2022-09-26 Thread wjoe via Digitalmars-d-learn
On Sunday, 25 September 2022 at 02:10:00 UTC, Salih Dincer wrote: On Saturday, 24 September 2022 at 13:17:19 UTC, rassoc wrote: Recently I refactored some old code of mine, now utilizing classes instead structs, and I got hit by an uninitialized variable access pattern similar to the simplified

Re: Detect uninitialized class var access

2022-09-25 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 25 September 2022 at 03:04:45 UTC, Tejas wrote: On Saturday, 24 September 2022 at 23:04:00 UTC, rassoc wrote: On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote: gdb --args ./your_program and then it will tell you all the details you want to know about when this happens.

Re: Detect uninitialized class var access

2022-09-24 Thread Tejas via Digitalmars-d-learn
On Saturday, 24 September 2022 at 23:04:00 UTC, rassoc wrote: On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote: gdb --args ./your_program and then it will tell you all the details you want to know about when this happens. Thank you for your input, Adam. Real shame that there's n

Re: Detect uninitialized class var access

2022-09-24 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 24 September 2022 at 13:17:19 UTC, rassoc wrote: Recently I refactored some old code of mine, now utilizing classes instead structs, and I got hit by an uninitialized variable access pattern similar to the simplified example below. I think changing the structure will make things h

Re: Detect uninitialized class var access

2022-09-24 Thread rassoc via Digitalmars-d-learn
On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote: gdb --args ./your_program and then it will tell you all the details you want to know about when this happens. Thank you for your input, Adam. Real shame that there's no built-in compiler solution and probably never will be accord

Re: Detect uninitialized class var access

2022-09-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 24 September 2022 at 13:17:19 UTC, rassoc wrote: just crashes with `Error: program killed by signal 11` on linux and nothing else. gdb --args ./your_program and then it will tell you all the details you want to know about when this happens. strangly sometimes adding the -O opti

Detect uninitialized class var access

2022-09-24 Thread rassoc via Digitalmars-d-learn
Recently I refactored some old code of mine, now utilizing classes instead structs, and I got hit by an uninitialized variable access pattern similar to the simplified example below. How can we easily spot this? What other switches and safeguards are there? > dmd -dip1000 -debug -g -w just cra