c++/6355: g++ 2.95.4 allows creation of pure virtual object by autoconversion

schrotie@uni-bielefeld.de schrotie@uni-bielefeld.de
Thu Apr 18 06:46:00 GMT 2002


>Number:         6355
>Category:       c++
>Synopsis:       g++ 2.95.4 allows creation of pure virtual object by autoconversion
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 18 06:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Thorsten Roggendorf
>Release:        2.95.4
>Organization:
>Environment:
debian woody up to date as of 18.4.02
custom linux kernel 2.4.18 built with gcc 2.95.4
>Description:
This code should be rejected, the bug can be pretty hard to find in complex code:

class Base {
public:
  Base(bool) {}
  virtual Base* clone() const = 0;
};

class Composition {
  Base* basePointer_;
public:
  Composition(const Base& basePointer) : basePointer_(basePointer.clone()) {}
};

int main() {
  Composition c(false);
}
>How-To-Repeat:
Compile the above code without any compiler options, execute a.out if you care.
>Fix:
Dunno.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list