Doc. No.: WG21/N2587
J16/08-0097
Date: 2008-03-16
Reply to: Mike Spertus Hans-J. Boehm
Phone: +1-312-961-7140
Email: mike_spertus@symantec.com Hans.Boehm@hp.com

N2587: Minimal Garbage Collection Status API

This is a proposal for a supplemental status API for N2586: "Minimal Support for Garbage Collection and Reachability-Based Leak Detection (revised)." At the request of the Library Working Group, this API is split into a separate proposal.

The goal of this proposal is to provide an API that a program can use to determine if garbage collection or leak detection as described in N2586 is enabled. Reasons this is useful include:

Library Wording

namespace std {
    enum invalidly_derived_pointer_behavior {
        invalid = 0;
        valid = 1;
        leak_detection = 2;
    };
}
invalidly_derived_pointer_behavior invalidly_derived_pointer_behavior_for_default_allocator()
Returns:
valid if all dynamically allocated memory is implicitly declared reachable [Note This guarantess C++03 behavior];
invalid if memory allocated by the global operator new is not declared reachable;
leak_detection in implementation-defined circumstances to indicate that although C++03 behavior is in effect, external tools such as leak detectors are enabled and may produce more accurate reports if declare_reachable declarations are used.

Observations and Issues