[Bug c++/60873] New: C++11: template class with const member and default ctor should fail to compile?
sebastian.hegler@tu-dresden.de
gcc-bugzilla@gcc.gnu.org
Thu Apr 17 13:00:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60873
Bug ID: 60873
Summary: C++11: template class with const member and default
ctor should fail to compile?
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sebastian.hegler@tu-dresden.de
Consider this minimal example:
template <typename T>
struct A {
const T s_;
A() = default;
A(const T& s) : s_(s) {};
};
int main() {
A<bool> b(true);
};
Now, A has a default ctor which isn't used, but AFAIK simply defining it as
default violates the standard, so clearly, my code is buggy.
I wonder, however, if gcc should reject the code, as ICC 2013 does:
error #409: "A<T>::A() [with T=bool]" provides no initializer for:
const member "A<T>::s_ [with T=bool]"
A<bool> b(true);
Thanks!
More information about the Gcc-bugs
mailing list