------- Additional Comments From aoliva at gcc dot gnu dot org 2005-02-16 17:27 ------- Getting a warning to be issued is easy: initialize_ref may print it if it finds that the call to convert_like will create a temporary, testing conv->need_temporary_p. However, this would trigger warnings for binding default args to reference parameters as well. If we get fndecl passed down from convert_for_initialization, and test for !fndecl as well, you get the correct warnings, but you still don't get correct behavior: the dtor for the temporary that appears in the mem-initializer-list should be called at the end of the ctor, i.e., after the body of the ctor. Currently, it's called too early. Reworking the reference initialization code to create a cleanup for the ctor body and pass that down shouldn't be too hard, but I've already used up the time slot I'd allocated for this bug. As for the life of a default arg, it does extend past the actual function call, which is correct, but it would probably be a plus to get it handled in the same way as other reference binding to args.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986