[llvm-bugs] [Bug 27637] New: creating object of abstract class allowed in all versions of clang++

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 3 23:39:50 PDT 2016


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: unassignedclangbugs at nondot.org
          Reporter: pravasimeet999 at yahoo.com
                CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160504/21384eeb/attachment.html>


More information about the llvm-bugs mailing list