From cfeda89f300b23dcf95abb431bd54020b6a27a53 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Apr 2024 16:16:44 +0200 Subject: Fix copying issue in odb-tests/common/view/olv/ --- odb-tests/common/view/olv/driver.cxx | 10 +--------- odb-tests/common/view/olv/test4.hxx | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/odb-tests/common/view/olv/driver.cxx b/odb-tests/common/view/olv/driver.cxx index c08015e..77cf76e 100644 --- a/odb-tests/common/view/olv/driver.cxx +++ b/odb-tests/common/view/olv/driver.cxx @@ -367,15 +367,7 @@ main (int argc, char* argv[]) transaction t (db->begin ()); session s; view2 v (db->query_value ()); - - // @@ BUILD2 As of cl 19.29.30136 (VS 2019 16.11.5) v.o2.o1 points to - // the address of o1 member of the object being returned by - // query_value() which v is a copy of, and thus the - // original assertion fails. Note that changing `view2 v` to - // `const view2& v` doesn't help. - // - //assert (v.o1.n == 123 && v.o2.s == "abc" && v.o2.o1 == &v.o1); - assert (v.o1.n == 123 && v.o2.s == "abc"); + assert (v.o1.n == 123 && v.o2.s == "abc" && v.o2.o1 == &v.o1); t.commit (); } diff --git a/odb-tests/common/view/olv/test4.hxx b/odb-tests/common/view/olv/test4.hxx index f2af5fd..4d8b804 100644 --- a/odb-tests/common/view/olv/test4.hxx +++ b/odb-tests/common/view/olv/test4.hxx @@ -6,6 +6,7 @@ #include #include // shared_ptr +#include #include @@ -90,6 +91,17 @@ namespace test4 object1 o1; object2 o2; + + view2 () {} + view2 (const view2& v) + : o1 (v.o1), o2 (v.o2) + { + if (v.o2.o1 != 0) + { + assert (v.o2.o1 == &v.o1); + o2.o1 = &o1; + } + } }; #pragma db view object(object1) object(object2) transient @@ -102,6 +114,17 @@ namespace test4 object1 o1; object2 o2; bool o2_null; + + view2a () {} + view2a (const view2a& v) + : o1 (v.o1), o2 (v.o2) + { + if (v.o2.o1 != 0) + { + assert (v.o2.o1 == &v.o1); + o2.o1 = &o1; + } + } }; // Test loading into raw pointer with non-raw object pointer. -- cgit v1.1