https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119323

--- Comment #13 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Robert Dubner from comment #11)
> But I really wonder if it's possible to come up with an example where using
> ++it is actually faster, in some significant way, than using it++.

Putting sleep( 1) in one of them should make a difference.
For example, for a typical Point class:

class Point
{
public:
   // Declare prefix and postfix increment operators.
   Point& operator++();       // Prefix increment operator.
   Point operator++(int);     // Postfix increment operator.
};

// Define prefix increment operator.
Point& Point::operator++()
{
   _x++;
   _y++;
   return *this;
}

// Define postfix increment operator.
Point Point::operator++(int)
{
   Point temp = *this;
   sleep( 1);
   ++*this;
   return temp;
}

In general, for types close to the machine like most STL iterators,
pre & post aren't that different. For complex types, they can be
very different.

> Anyway, I have a local script for running tests.  I am considering adding
> cppcheck to the end of it.  Like, why not?

Good idea. 

The thought crosses my mind that cobol hasn't AFAIK met clang. 
Build running. I will report back, probably in a separate bug report.

Reply via email to