This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: another effc++ spurious warning?


Paolo Carlini wrote:

> The relevant item is 24.5.4.2, p4: according to it "[operator++(int)]
> Returns: *this."
>
> Therefore, I cannot see anything wrong with our implementation:
>
>       /// Return *this.
>       ostreambuf_iterator&
>       operator++(int)
>       { return *this; }

Hi Paolo, there is nothing wrong here of course. The rule of the thumb rule
spotted by -Weffc++ is that a postfix operator++ should return a temporary copy
of the original object before its increment, so you cannot do that sanely if
you return a reference. Think of "(a++)++".

Of course, this does not make sense in the case of input/output iterators,
because a "copy" does not respect the usual copy semantic. I am not sure how we
can tackle this for -Weffc++. Maybe Benjamin was planning to turn off this
specific warning while compiling v3, but there is still a problem when
including the header in user code.

If there are no ideas about how to make the warning smarter, maybe it is better
to disable this very check

Giovanni Bajo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]