Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Warnings in C::B
oBFusCATed:
Today, I was reading the C++ FAQ and found something interesting:
http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.9
thomas:
I think the issue is really that these are not overloaded virtual functions at all, since one passes the parameter by value and the other passes the parameter by const reference.
And though this is a serious error rather than some pedantic sophistry, it so happens that the compiler seems to incidentially pick the "correct" function (const&), as it happens to be the one that optimizes better.
Now, the right solution would be, obviously, to change the base class (and all other derived classes that might have a wrong signature too) to const reference. However, that would mean that we break the SDK's interface (which we agreed on some 1-1.5 years ago shouldn't be done). Yiannis?
oBFusCATed:
--- Quote from: thomas on September 28, 2010, 02:00:00 pm ---I think the issue is really that these are not overloaded virtual functions at all, since one passes the parameter by value and the other passes the parameter by const reference.
--- End quote ---
There are also functions with different number of parameters.
Also there are virtual operator= which are totally wrong (search google for info).
MortenMacFly:
--- Quote from: thomas on September 28, 2010, 02:00:00 pm ---However, that would mean that we break the SDK's interface (which we agreed on some 1-1.5 years ago shouldn't be done). Yiannis?
--- End quote ---
IIRC we agreed not to break in in the release branches (08/02 and 10/05), but in trunk I'm afraid we have already several times, not to mention the developer branches.
thomas:
--- Quote from: oBFusCATed on September 28, 2010, 03:12:18 pm ---There are also functions with different number of parameters.
--- End quote ---
Well yes, obviously, and that's nothing to worry about.
But in this case, the apparent/obvious intent is to overload a base class' function. It's just not what is done, and the fact that it works is pure coincidence. Thus I say that it's actually a severe error.
--- Quote from: oBFusCATed on September 28, 2010, 03:12:18 pm ---Also there are virtual operator= which are totally wrong (search google for info)
--- End quote ---
While I'm not sure how it makes sense to overload the assignment operator, I don't see a real hindrance to doing that. After all, operator= is just a function, like every other function. In fact, SetTargetType could be thought of a kind of "partial" operator=.
Which, again, makes me wonder (only judging from the function's name, without actually looking at the implementation) if it's necessary to overload such a function. It actually shouldn't ever need to be any different than the one in the base class. But well, there may be some call to UpdateFoobar() which is necessary in one and not the other, I sadly don't have the time to dig through source now to look.
Navigation
[0] Message Index
[*] Previous page
Go to full version