search for: init_b

Displaying 3 results from an estimated 3 matches for "init_b".

Did you mean: init_s
2018 Mar 19
4
RFC: Devirtualization v2
...that we could somehow avoid it, but because virtually no one is using unions this way, this should not cause any problems.struct A { virtual void foo();};struct B : A { void foo() override;};union U { A a; B b; U() : b() {}};void do_call(A &a) { a.foo();}__attribute__((noinline)) void init_B(U &u) { new(&u.b) B;}void union_test(U &u) { do_call(u.b); new(&u.a) A; do_call(u.a); init_B(u); do_call(u.b);}int main() { U u; union_test(u);}Ptr to intIn this example, instead of comparing the pointers we compare the addresses stored in integers. Because ptrtoint...
2018 Mar 28
0
[cfe-dev] RFC: Devirtualization v2
...ms. > > struct A { > virtual void foo(); > }; > > struct B : A { > void foo() override; > }; > > union U { > A a; > B b; > U() : b() {} > }; > > void do_call(A &a) { > a.foo(); > } > > __attribute__((noinline)) void init_B(U &u) { > new(&u.b) B; > } > > void union_test(U &u) { > do_call(u.b); > new(&u.a) A; > do_call(u.a); > > init_B(u); > do_call(u.b); > > } > > int main() { > U u; > union_test(u); > } > Ptr to int >...
2018 Mar 29
2
[cfe-dev] RFC: Devirtualization v2
...ow avoid it, but because virtually > no one is using unions this way, this should not cause any problems.struct > A { virtual void foo();};struct B : A { void foo() override;};union U { > A a; B b; U() : b() {}};void do_call(A &a) { > a.foo();}__attribute__((noinline)) void init_B(U &u) { new(&u.b) > B;}void union_test(U &u) { do_call(u.b); new(&u.a) A; do_call(u.a); > init_B(u); do_call(u.b);}int main() { U u; union_test(u);}Ptr to > intIn this example, instead of comparing the pointers we compare the > addresses stored in integer...