This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GCC do not honor casting when calling constructors from constructors


I'm not sure if this is a bug of gcc or a feature of C++ syntax. Sending
it in anyway.
When I compile the following code, the class Camera1 is OK but Camera2
fails with the following
error:

---------------------------------------------
[rosbacke@rosbacke-pc world]$ gcc -c test.cpp -o test.o
test.cpp: In method `Camera2::Camera2()':
test.cpp:20: no matching function for call to `Camera2::Camera2 (double,
double, double)'
test.cpp:19: candidates are: Camera2::Camera2(const Hvec &)
test.cpp:20:                 Camera2::Camera2()
test.cpp:22:                 Camera2::Camera2(const Camera2 &)
 [rosbacke@rosbacke-pc world]$
--------------------------------------------

The file test.cpp contains the following:

-----------------------------------------------
class Hvec
{
 public:
  Hvec(double x, double y, double z);
  ~Hvec();
};


class Camera1
{
 public:
  Camera1(const Hvec &basepos=Hvec(0.0,0.0,0.0));
  ~Camera1();
};

class Camera2
{
 public:
  Camera2(const Hvec &basepos);
  inline Camera2() { Camera2(Hvec(0.0,0.0,0.0)); };
  ~Camera2();
};
---------------------------------------------

Using Redhat 6.1 with kernel 2.2.14 and gcc 2.95.2. gcc -v gives:

---------------------------------------------
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
---------------------------------------------

--- Mikael Rosbacke



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]