[Coin-discuss] Compiling Osi with gcc 2.95.3
Michael Hennebry
hennebry at web.cs.ndsu.nodak.edu
Tue Feb 22 12:05:59 EST 2005
On Mon, 21 Feb 2005, Lou Hafer wrote:
> Mike's example is correct in principle. Forte C++ differs on the
> mixed cases. Possibly because it's not possible to construct a bare OsiCut
> object (protected constructor). The best that can be done is point at an
> OsiColCut with an OsiCut pointer or reference. I crafted an example which
> exploits extra tests in the derived OsiColCut::operator==, and got the
> following result:
>
> base == base uses OsiCut::operator==
> base == derived uses OsiCut::operator==
> derived == base uses OsiCut::operator== ; compile error without `using'
I had to punt on this case because from Stroustrup's book, I couldn't
tell what was supposed to happen.
Eventaully I found an example.
>From the example, conversion of the left side of the operator is allowed.
In the example, the left side was 3, not an instance of a derived class.
> derived == derived uses OsiColCut::operator==
>
> Apparently Forte is unwilling to fall back to OsiCut::operator== unless the
> `using' declaration is in place, and thus warns about it.
There seems to be a difference in rules interpretation here.
Forte wants to do the conversion as a conversion, but can't make
the temporary because of the protected constructor.
gcc is willing to do the conversion by applying the is-a principle
and using only the base of the left side.
Whether it would do that without the const modifier I know not.
> Forte generates similar warnings in many other parts of COIN.
>
> The visible tradeoff is gcc 2.95 compatibility vs. a reduction in
> Forte warning messages and some extra flexibility that is most likely unused.
A cure that does not involve the preprocessor is to forgo usings
and redefine functions in derived classes that call their namesakes
in the base classes.
Even a simple optimizer should be able to elide the extra call.
--
Mike hennebry at web.cs.ndsu.NoDak.edu
"Our gods are dead. Ancient Klingon warriors slew them
... they were more trouble than they were worth." -- Worf
More information about the Coin-discuss
mailing list