https://llvm.org/bugs/show_bug.cgi?id=27637

            Bug ID: 27637
           Summary: creating object of abstract class allowed in all
                    versions of clang++
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: pravasimeet...@yahoo.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
    Classification: Unclassified

Created attachment 16308
  --> https://llvm.org/bugs/attachment.cgi?id=16308&action=edit
bug in clang++

clang++ 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/uT43g5lw26HWAbog )

#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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to