This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: another effc++ spurious warning?
- From: Matt Austern <austern at apple dot com>
- To: Giovanni Bajo <giovannibajo at libero dot it>
- Cc: libstdc++ at gcc dot gnu dot org, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 8 Jul 2004 10:22:18 -0700
- Subject: Re: another effc++ spurious warning?
- References: <066601c464e7$26741020$a54a2597@bagio>
On Jul 8, 2004, at 5:29 AM, Giovanni Bajo wrote:
Benjamin,
I see many instances of this while compiling with -Weffc++:
/home/farfetch/gcc/mainline/out/i686-pc-linux-gnu/libstdc++-v3/
include/bits/str
eambuf_iterator.h:235: warning: postfix
`std::ostreambuf_iterator<_CharT,
_Traits>& std::ostreambuf_iterator<_CharT, _Traits>::operator++(int)
[with
_CharT = wchar_t, _Traits = std::char_traits<wchar_t>]' should return
`std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> >'
What is your position on this? I did not check the code, but shouldn't
operator++(int) return a temporary? Or maybe not for output/input
iterators?
istream_iterator and ostream_iterator are sort of a special case. The
standard (clauses 24.5.1.2 and 24.5.2.2) require operator++(int) to
return a reference, not a temporary. When you think about how these
iterators are implemented you'll see that the standard is correct:
"increment" doesn't really do anything.
--Matt