Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I found that "x = y" invoking custom code brings serious consequences.
- Jellyfish treats `x = y` as destruction of x, followed by a copy ctor.
- For a brief moment of time, `x` is in an indeterminate state. This is not
- a problem for memcpy, as no other part of the program can observe this brief
- inconsistency. But if we allow custom operator=, then this incosistency may
- become visible to the rest of the program if = does some funny stuff.
- Consider
- struct Foo{
- field bar:Bar;
- }
- function f(x:ref Foo){
- x->bar = make_bar();
- }
- In this case, the `Bar` destructor is invoked first. So `x->bar` becomes
- uninitialized. Then it invokes a copy ctor, but if there are more references to
- `x`, and this copy ctor uses one of them to access it, then they'll see `Foo`
- in an incosistent state.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement