2 ms·
> Fair point, I was indeed being insufficiently precise. That code is a typical example of how const helps performance OK, well, I was merely saying you need a
by wfunction 10y ago
> Fair point, I was indeed being insufficiently precise. That code is a typical example of how const helps performance
OK, well, I was merely saying you need a citation for the situation we were discussing. I still stand by it.
> I think the MSVC devs classify it as a codegen bug since the cause is a logic error in the optimizer.
I'm gonna pull your own type of argument here, which is that they only consider it a bug because they have their own stricter guidelines for what they expect, not because it's actually a general language implementation bug. Definitely not something I'd call an "outright compiler bug" when the code is behaving sanely.
> When you say using const has given you trouble many times, do you have any particularly poignant example in mind?
I don't have a particularly poignant one at the top of my head right now, but I can give you a hypothetical one to illustrate the idea. Look at std::binary_negate (for our purposes assume the functor is required to be const-callable). People put const on the instance field of that sort of thing because, well, everything that can be const should be const dammit! Except now it gives you hell trying to assign to the object. That's the issue.