Hi. Check this out:
vector<CL_Texture> v;
CL_DisplayWindow w("", 0, 0);
v.push_back(CL_Texture(w->get_gc(), 0, 0));
What happens here?
Careless coder declares a vector. AFTER that he creates a window. Then he goes on to make himself a texture. He plans to iterate over the vector later, and draw his textures.
Now we go out of scope. The window was declared last so it's destructed FIRST. The gc becomes invalid. Vector goes out of scope, destructs its texture, we call clDeleteTextures on an invalid gc_provider. Segfault, bang, we're dead.

If the vector was declared after the window, this wouldn't happen. But it's really error prone and not obvious where the crash comes from. The API shouldn't let me do this stuff.

How should we solve this? The GC could keep a list of all its textures, then notify all of them when it's destructed. They take note and set a flag which they check before doing clDeleteTextures in the dtor.

This sounds inefficient, cause the GC would waste memory on safe-netting me. Still IMO it's worth it. What do you think?