This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45963] New: inconsistent and poor array initialization diagnostic


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) {}
                    ^


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]