From: "Andrew Reid" Newsgroups: comp.os.msdos.djgpp Subject: problem with new[] using djgpp egcs Date: Fri, 2 Apr 1999 16:27:41 +1200 Organization: University of Canterbury Lines: 33 Message-ID: <7e1h02$7nu$1@cantuc.canterbury.ac.nz> NNTP-Posting-Host: acr28.tacacs.canterbury.ac.nz X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I'm having a problem with the standard new[] operator The following code (a simple example) compiles and works fine with the djgpp(2.02) port of gcc 2.81, and with egcs under Redhat Linux 5.2, but causes an error when I try to use egcs 1.1.2 for djgpp or pgcc for linux int main( void ) { int* x = new int[5](0); } The error message I get is: request for member `__ct' in `*{anon}', which is of non-aggregate type `int' and obviously the compiler is going to get stuck if it's trying to find members of a built in type What is also interesting is the fact that compiling the statement T* x = new T[n]( const T& ) never causes any problems unless T is a builtin type. My application of this code is in a template class where not all the types that the template is instantiated for have a default constructor, so I need to provide a default object of type T to the new operator. I have a number of questions: Does anyone know why this won't compile under egcs for djgpp while gcc appears to be happy? Am I using the wrong libraries or headers? or perhaps I need a different version of the compiler? Is this standard c++? If it isn't, then how should I tackle my problem in a standard compatible manner? Thanks heaps - any help will be much appreciated