This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26604] New: primitive type initialisation in array allocation
- From: "allali at univ-mlv dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Mar 2006 12:07:25 -0000
- Subject: [Bug c++/26604] New: primitive type initialisation in array allocation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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