This is the mail archive of the mailing list for the GCC 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: Volatile MEMs in statement expressions and functions inlined as trees

On Dec 14, 2001, Linus Torvalds <> wrote:

> If you override the assignment operator, then the rules of assignment are
> defined by _you_, not by the C++ standard.

Indeed.  I  actually had the implicitly-defined assignment operator in
mind, but it doesn't apply to volatile objects, so I wasn't making any

> before anybody shoots
> me for this offense against humanity, I'd like to point out that I have
> never _ever_ done this in real life, and I don't encourage people to write
> code like this):


> Yet the above is, as far as I can tell, perfectly legal C++ code.

If I were you, I'd have made the assignment operator= const too, just
for the fun of it.  Just think of it: an assignment operator that
cannot modify its left operand! :-)

> So I think (and this time I'm _positive_ that Gabriel will agree) that the
> C++ assignment rules only cover the _standard_ assignments, not the ones
> you come up with yourself by overloading the operator.

Still, it would be nice if it were *possible* to implement similar
semantics to the (lvalue,stored-rvalue) pairs that you propose for
built-in assignment operators.  But that's impossible, which makes me
wonder if it built-in operators should have this same semantics.

> PS. I don't know whether there is an "Obfuscated C++" competition or not,
> but if there is, overloading of operators should be banned

Then you pretty much can't use iostreams, vectors, valarrays and many
other standard components of the C++ library.  Like it or not,
operator overloading is used a lot in the standard language, and for
good, IMO.

> simply because it makes it too easy. It's like shooting fish in a
> barrel - it's just not a sport any more.


Alexandre Oliva   Enjoy Guarana', see
Red Hat GCC Developer                  aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
Free Software Evangelist    *Please* write to mailing lists, not to me

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