I'm inclined to believe reworking not to assume stability of references is easier, given how one of the two proposed fixes did that and basing on my tests it's stable. Sure,other cases may still be broken but it does not result in any new issues.
I don't think the usage pattern exemplified here is unique. If one doesn't know whether a particular vectors will ever be expanded large enough to require relocation, or whether any code might rely upon its address being stable, then replacing them with instances that won't relocate would serve to prevent the worse-than-useless behavior of leaving dangling references. If it turns out the vectors would need to be expanded more than could be predicted when they are created, then one could inspect all uses thereof to ensure that expansion would be safe before enabling it, but if it turns out that the vectors never need to be moved, then one wouldn't have to worry about trying to inspect all code that might possibly be relying upon their addresses being stable.
1
u/CookiePLMonster Feb 02 '20
I'm inclined to believe reworking not to assume stability of references is easier, given how one of the two proposed fixes did that and basing on my tests it's stable. Sure,other cases may still be broken but it does not result in any new issues.