[Coin-discuss] Warnings when compiling with Sun Forte 6u2 compiler
Jonathan Eckstein
jeckstei at rutcor.rutgers.edu
Mon Jul 7 15:08:22 EDT 2003
Hello, COIN-ers:
We PICO people have been using COIN's OSI as an LP solver interface on
various platforms. I have had a lot of trouble getting the gnu 3.x
compilers to work on my Sun, and have recently been using the Sun
Workshop/Forte 6u2 compilers.
Using these compilers, we get the following warnings repeatedly:
"/home/jeckstei/alt-sandbox/COIN/include/OsiRowCut.hpp", line 154:
Warning: OsiRowCut::operator== hides the virtual function
OsiCut::operator==(const OsiCut&) const.
"/home/jeckstei/alt-sandbox/COIN/include/OsiRowCut.hpp", line 154:
Warning: OsiRowCut::operator!= hides the virtual function
OsiCut::operator!=(const OsiCut&) const.
"/home/jeckstei/alt-sandbox/COIN/include/OsiColCut.hpp", line 145:
Warning: OsiColCut::operator== hides the virtual function
OsiCut::operator==(const OsiCut&) const.
"/home/jeckstei/alt-sandbox/COIN/include/OsiColCut.hpp", line 145:
Warning: OsiColCut::operator!= hides the virtual function
OsiCut::operator!=(const OsiCut&) const.
We have been ignoring these warnings for over a year, but recently my
student Konrad Borys brought to my attention a passage on page 235 of
"Effective C++" (second edition) by Scott Myers, where he talks about
this kind of situation. The method
inline virtual bool operator==(const OsiCut& rhs) const;
declared in OsiCut.hpp cannot be used on an object of type OsiRowCut,
even though it inherits from OsiCut, because there is a method in
OsiRowCut with the slightly different prototype
OsiRowCut_inline bool operator==(const OsiRowCut& rhs) const;
Thus, if "obj1" is an OsiRowCut and "obj2" is an OsiCut, the expression
obj1 == obj2
or certainly
obj1.operator==(obj2)
should generate an error.
I am wondering if this design is intentional, or whether the Sun
compiler is catching an unintentional problem the Gnu compilers are
missing? I quite possibly could be missing something, as I am not
completely clear on some of the darker crannies of C++.
Thoughts?
Thanks,
Jonathan
--
Associate Professor Jonathan Eckstein
MSIS Department, Rutgers Business School, Rutgers University
TEACHING ADDRESS RESEARCH ADDRESS
+------------------------------+--------------------------------+
| 255 J.H. Levin Building | RUTCOR, Room 155 |
| 94 Rockafeller Road | 640 Bartholomew Road |
| Livingston Campus | Busch Campus |
| Rutgers University | Rutgers University |
| Piscataway, NJ 08854 USA | Piscataway, NJ 08854 USA |
| (732) 445-0510 | (732) 445-3272 |
| FAX (732) 445-6329 | FAX (732) 445-5472 |
+------------------------------+--------------------------------+
jeckstei at rutcor.rutgers.edu
http://rutcor.rutgers.edu/~jeckstei/
More information about the Coin-discuss
mailing list