------- Comment #10 from pinskia at gcc dot gnu dot org 2006-01-23 22:23 ------- (In reply to comment #9) > Of course, the compiler (more precisely the middle-end) knows that the > destructor has a side-effect. But GCC middle-end tends to have little > knowledge of language specific idioms. Notice also that a is "used" > from a very high level abstraction point of view -- not from byte-fiddling > point of view. This is another instance of diagnostic PR better handed off > to the front-end.
Actually the diagnostic is done in the front-end in cp/decl.c in poplevel. /* Before we remove the declarations first check for unused variables. */ if (warn_unused_variable && !processing_template_decl) for (decl = getdecls (); decl; decl = TREE_CHAIN (decl)) if (TREE_CODE (decl) == VAR_DECL && ! TREE_USED (decl) && ! DECL_IN_SYSTEM_HEADER (decl) && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) warning (0, "unused variable %q+D", decl); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10416