https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70939

            Bug ID: 70939
           Summary: creating object of abstract class allowed in all
                    versions of g++
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pravasimeet999 at yahoo dot com
  Target Milestone: ---

Created attachment 38408
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38408&action=edit
g++ compiles ill formed C++ program successfully

The following program is ill formed C++ program because it is not allowed to
create objects of abstract class. But in all versions of g++ the program
compiles successfully.

This question originally asked on stackoverflow by user Matt. See here:
http://stackoverflow.com/questions/37017094/why-do-gcc-and-clang-allow-me-to-construct-an-abstract-class
.

(See live demo here: http://melpon.org/wandbox/permlink/U7PeIkEPT19BfguJ )
#include <stdio.h>

class A
{
public:
    A() {
        printf("A()\n");
    }
    virtual void b() const = 0;
};

int main()
{
    const A& a{};
    a.b();
    return 0;
}

The program is clearly invalid &  implementation is required to produce a
diagnosis for this according to C++ standard.

Reply via email to