brintos

brintos / llvm-project-archived public Read only

0
0
Text · 420 B · 4b3b695 Raw
20 lines · cpp
1// This structure has a non-trivial copy constructor so2// it needs to be passed by reference.3struct PassByRef {4  PassByRef() = default;5  PassByRef(const PassByRef &p){x = p.x;};6 7  int x = 11223344;8};9 10PassByRef returnPassByRef() { return PassByRef(); }11int takePassByRef(PassByRef p) {12    return p.x;13}14 15int main() {16    PassByRef p = returnPassByRef();17    p.x = 42;18    return takePassByRef(p); // break here19}20