the code:
----------------------------
class A{
public:
    A(int i){}
};

int main(){
A *a=new A[10](2);
int *p=new int[10](3);
}
------------------------------
2 problems:
1. This code compiles with g++ -Wall -ansi (no warning)
put I think that array initialisation is 
forbidden in ANSI (the compilation failed with
--pedantic)
2. For the array "a", elements are correctly
constructed with A::A(2). For "p", values
in the array are not equals to 3 ! ("copy 
constructor" is not call for primitive types)

Regards
    Julien Allali.


-- 
           Summary: primitive type initialisation in array allocation
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: allali at univ-mlv dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26604

Reply via email to