Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string func() { /* ... */ }
- const std::string& s = func();
- std::cerr << s << '\n'; // OK
- struct A {
- const std::string& s;
- A(): s(func()) {}
- };
- A a;
- std::cerr << a.s << '\n'; // UB !!!
Advertisement
Add Comment
Please, Sign In to add comment