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]
Other format: [Raw text]

[Bug c++/11928] New: c++ typedef handling


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11928

           Summary: c++ typedef handling
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org

[forwarded from http://bugs.debian.org/205402]

g++-3.3 fails to compile the code in test.cc with the following message: 
test.cc: In function `int main(int, char**)':
test.cc:22: error: conversion from `BClass' to `B*' is ambiguous
test.cc:16: error: candidates are: BClass::operator B*()
test.cc:9: error:                 AClass::operator A*()

Although it correctly compiles the equivalent code in test2.cc

--- begin test.cc ---
typedef struct _A A;
typedef struct _A B;

void some_function(B *b);

class AClass {

public:
  operator A*() { return 0;}

};

class BClass :public AClass {

public:
  operator B*() { return 0;}

};

int main(int argc, char **argv) {
  BClass b;
  some_function(b);
}
--- end test.cc ---

--- begin test2.cc ---
void some_function(struct _A *b);

class AClass {

public:
  operator struct _A*() { return 0;}

};

class BClass :public AClass {

public:
  operator struct _A*() { return 0;}

};

int main(int argc, char **argv) {
  BClass b;
  some_function(b);
}
--- end test2.cc ---


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