This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
annoying warning message
- To: bug-gcc at gnu dot org
- Subject: annoying warning message
- From: Stefan Seefeld <seefelds at MAGELLAN dot UMontreal dot CA>
- Date: Tue, 14 Sep 1999 18:19:47 +0000
Hi,
the following program produces a warning message though
I believe it is well formed.
-----------------------------------
template <class T>
class Var
{
public:
Var(T *tt) : t(tt) {}
~Var() { delete t;}
operator const T &() const { return *t;}
operator T &() { return *t;}
private:
T *t;
};
struct Vertex { double x, y, z;};
typedef Var<Vertex> Vertex_var;
void foo(const Vertex &) {}
int main(int, char **)
{
Vertex_var vertex = new Vertex;
foo(vertex);
};
--------------------------------------
the warning message (using g++ 2.95) is
const.cc:24: warning: choosing `Var<Vertex>::operator Vertex &()' over `Var<Vertex>::operator const
Vertex &() const'
const.cc:24: warning: for conversion from `Vertex_var' to `const Vertex &'
const.cc:24: warning: because conversion sequence for the argument is better
const.cc:18: warning: in passing argument 1 of `foo(const Vertex &)'
Who is right ?
Thanks, Stefan
PS: In fact, the above is modeled after omniORB's implementation of
var types. Since we use this kind of stuff a lot in our project we
get lots of those warning messages.
_______________________________________________________
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca
_______________________________________________________
...ich hab' noch einen Koffer in Berlin...