This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45963] New: inconsistent and poor array initialization diagnostic
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Oct 2010 05:59:30 +0000
- Subject: [Bug c++/45963] New: inconsistent and poor array initialization diagnostic
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45963
Summary: inconsistent and poor array initialization diagnostic
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: igodard@pacbell.net
This code:
class foo {
public:
foo(int i): i(i) {}
foo() : i(0) {}
int i;
};
class bar {
public:
bar() : a(1) {}
bar(bool) : b(1) {}
bar(int) : b() {}
int a[5];
foo b[5];
};
int main() {
return 0;
}
gets you this:
s3:~/ootbc/members$ g++ foo.cc
foo.cc: In constructor âbar::bar()â:
foo.cc:9: error: incompatible types in assignment of âintâ to âint [5]â
foo.cc: In constructor âbar::bar(bool)â:
foo.cc:10: error: bad array initializer
In contrast, Comeau gives:
"ComeauTest.c", line 9: error: only "()" is allowed as initializer for array
member
"bar::a"
bar() : a(0) {}
^
"ComeauTest.c", line 10: error: only "()" is allowed as initializer for array
member
"bar::b"
bar(bool) : b(0) {}
^