Skip to content

Terrible error on implicitly deleted default constructor in C++0x mode #11183

@llvmbot

Description

@llvmbot
Bugzilla Link 10811
Resolution DUPLICATE
Resolved on Oct 10, 2011 14:24
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

$ cat test.cc
struct hash_int {
int operator()(int i);
};

class Hasher {
const hash_int hash_;
};

void foo() {
Hasher h;
}
$ clang++ -std=c++0x -c test.cc
test.cc:10:12: error: call to deleted constructor of 'Hasher'
Hasher h;
^
test.cc:5:7: note: function has been explicitly marked deleted here
class Hasher {
^
1 error generated.


The C++98 error does a better job:

$ clang++ -c test.cc
test.cc:5:7: error: implicit default constructor for 'Hasher' must explicitly initialize the const member 'hash_'
class Hasher {
^
test.cc:6:20: note: 'hash_' declared here
const hash_int hash_;
^
test.cc:10:12: note: implicit default constructor for 'Hasher' first required here
Hasher h;
^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11duplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions