On Tue, Jan 5, 2010 at 1:48 PM, Roy Stogner <[email protected]> wrote: > > On Tue, 5 Jan 2010, Andrea Hawkins wrote: > >> solution vector in gdb, but it never caught in between where I know it >> exists and then it doesn't. I've tried commented everything out, and >> adding >> lines to see when it fails, and surprisingly it fails when the line >> >> TransientNonlinearImplicitSystem system = >> es.get_system<TransientNonlinearImplicitSystem>("Cahn-Hilliard-Init"); >> >> is added... >> >> Is there something about getting a reference to a system where I would >> need >> to close it or something? > > Yup, here's the bug. > > Your problem is that you want to be declaring a reference and you're > accidentally declaring a new object. > > Your fix is simple: add one ampersand to get > TransientNonlinearImplicitSystem &system = > es.get_system<TransientNonlinearImplicitSystem>("Cahn-Hilliard-Init"); > > Our problem is that our System classes are non-copyable, but we > haven't disabled the default System copy constructor. So when you > accidentally copy a System, the compiler calls the copy constructor on > all its members, and the solution AutoPtr on the original System gets > invalidated. > > I'm not sure what our fix should be. Probably a private do-nothing > (or do-libmesh_error) copy constructor, so that this kind of mistake > gets caught at compile time? The compiler error would be confusing, > but probably not as confusing as wondering why your solution pointer > appears to randomly invalidate itself.
Wow, good find. I guess I'd prefer the compile-time error, rather than runtime. It's usually easier to debug compiler messages than runtime errors. This is C++, though, so strong emphasis on "usually". -- John ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Libmesh-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-users
