@6502 Maybe on a bad compiler. I agree it's a problem, but it's not a correctness problem, it's an optimization problem. That is, the code is required to work as you expect but this means the compiler can't perform certain optimizations unless it can prove certain things.

@gman: sorry, but it's perfectly legal to pass both a reference and a const reference to the same object, and the compiler MUST consider that the const-referenced object may change. a const reference is never an help for the optimizer. const-correctness of references has beed designed as an help for PROGRAMMERS, not for the compiler

@frerich: reference to const is a misleading naming, because as I told before it's not true that the referenced object is const. If I pass a function a const Rect&`it doesn't mean that the referenced rect is constant during the function... just that the compiler should forbid changing the rect using the reference. In `const Rect& the word const is talking of a property of &, not of the rect.

@gman: I'm just saying that it's widespread practice to just pass a const reference instead of a value for objects, like if it's the same thing. This leads to subtle bugs because lifetime (e.g. the object referenced disappears in the middle of the function) or aliasing (it mutates). So I don't like saying people "just pass const references around"...

@6502 Understood. I'm also reconsidering the advice in general, now that you mention it. Perhaps for big objects it's a good idea (though with C++0x that could change too), but often it could be faster to work with a local copy (better cache locality and no aliasing), and CPU's are so quick when it comes to copying data anyway...

i have always feared to ask this on SO, but since i've read somewhere that even comm. memebrs (can i call them "offficial experts") had different opinions on some namespace peculiarities, i began to wonder whether it is possible to grasp the standard well enough to be pretty much sure what should happen in each corner case.

@James I've watched some whom I consider experts at youtube, does that? ::)