On Tue, 2019-01-08 at 09:59 -0500, Steven Schveighoffer via Digitalmars-d- learn wrote: > […] > > Russel, make sure your destructor both checks whether the underlying > resource is set, and clears it to invalid when freeing it. > > Even types that can't be copied can be moved, or temporarily created as > rvalues. When they are moved the shell they get moved out of is still > destructed! So it has to have a state where it can be destroyed, even > though there is no resource.
I have added tests in the destructor but given the constructor should throw an exception on a failure to initialise the internal state correctly, it really ought to be unnecessary. but I guess it cant hurt being there! As I noted to Nicholas it seems the application is getting a valid data structure returned with invalid data and that is where the SIGSEGV is. This is really weird as I have just finished a Rust version of the same application and it works fine. And this D version used to work fine. It is a real mystery why there is a problem now. Sadly the D plugin to CLion doesn't as yet have the same functionality as the Rust plugin. Debugging these sorts of thing is just so much better in CLion than trying to work GDB manually. > Maybe some inspiration here: > https://github.com/MartinNowak/io/blob/master/src/std/io/file.d#L189-L196 > I will check that out, thanks for the pointer. -- Russel. =========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part