Drop Flags

    Note that this is not a problem that all assignments need worry about. Inparticular, assigning through a dereference unconditionally drops, and assigningin a unconditionally doesn’t drop:

    This is only a problem when overwriting a previously initialized variable orone of its subfields.

    Of course, it is often the case that a value’s initialization state can bestatically known at every point in the program. If this is the case, then thecompiler can theoretically generate more efficient code! For instance, straight-line code has such static drop semantics:

    Similarly, branched code where all branches have the same behavior with respectto initialization has static drop semantics:

    Of course, in this case it’s trivial to retrieve static drop semantics:

    The drop flags are tracked on the stack and no longer stashed in types thatimplement drop.