https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69020
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- I agree, but as long as the feature is exposed to users it seems that it should work in unsurprising ways (i.e., follow the C++ lookup rules). Otherwise, if we don't want C++ programmers to use it, a possible simple fix is to reject the attribute in C++. Alternatively, we could reject it when the referenced function is dependent to keep it working in the cases we know work correctly and prevent unexpected results in the others. Or we can fix it and issue a warning suggesting to use a destructor. I'm fine with any of these solutions and I'm happy to work up a patch (in fact, I already started working on it hoping for a simple fix).