[LLVMbugs] [Bug 7411] New: Extra and confusing "no default constructor" messages when broken default constructor is confused with missing default constructor.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 18 11:22:12 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7411

           Summary: Extra and confusing "no default constructor" messages
                    when broken default constructor is confused with
                    missing default constructor.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: quality-of-implementation
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


If we create a class whose default constructor fails to instantiate, and
provoke the error for that, clang seems to mark the class as not having a
default constructor. Then later attempts to use this default constructor claim
it's missing, rather than drilling down to the root cause (or being suppressed
entirely). In the following test case, commenting out the "Broken b" line
improves the error message for the "Base<Broken> bb" line, and commenting out
both improves the message for the "Derived<Broken> db" line.


$ cat test.cc
struct NoDefault {
  NoDefault(int);
};
struct Broken{
  NoDefault nd;
};

template<typename T>
struct Base {
 protected:
  T t;
};
template<typename T>
struct Derived : Base<T> {
};

Broken b;
Base<Broken> bb;
Derived<Broken> db;

$ ./clang++ -fsyntax-only test.cc -Wall -Wextra
test.cc:4:8: error: implicit default constructor for 'Broken' must explicitly
initialize the member 'nd' which does not have a default constructor
struct Broken{
       ^
test.cc:5:13: note: member is declared here
  NoDefault nd;
            ^
test.cc:1:8: note: 'NoDefault' declared here
struct NoDefault {
       ^
test.cc:17:8: note: implicit default constructor for 'Broken' first required
here
Broken b;
       ^

test.cc:9:8: error: implicit default constructor for 'Base<Broken>' must
explicitly initialize the member 't' which does not have a default constructor
struct Base {
       ^
test.cc:11:5: note: member is declared here
  T t;
    ^
test.cc:4:8: note: 'Broken' declared here
struct Broken{
       ^
test.cc:18:14: note: implicit default constructor for 'Base<Broken>' first
required here
Base<Broken> bb;
             ^

test.cc:14:8: error: implicit default constructor for 'Derived<Broken>' must
explicitly initialize the base class 'Base<Broken>' which does not have a
default constructor
struct Derived : Base<T> {
       ^
test.cc:9:8: note: 'Base<Broken>' declared here
struct Base {
       ^
test.cc:19:17: note: implicit default constructor for 'Derived<Broken>' first
required here
Derived<Broken> db;
                ^
3 errors generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list