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]

new type (initializer) --- bug ???


Hi,

I have found the following Problem, which is new in
the current revision of egcs-g++. 

When one gives an initializer to the new operator, it
compiles with aggregate types, but not with built in ones.

The following code:

#include <stream.h>
#include <new>

class test {
public:
  double d;
  test() : d(0.0) {};
  test(double a) : d(a) {};
};

int main () {

  test*   da=new test[2](5.0);
  double* dp=new double[2](1.0);

  cout << *dp << "\t"
       << da[0].d << "\t"
       << da[1].d << endl;
}

compiled with the command "g++ -v test.cc" produces the following
output:

Reading specs from /usr/users/schopper/local/lib/gcc-lib/alphaev5-dec-osf4.0d/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
 /usr/users/schopper/local/lib/gcc-lib/alphaev5-dec-osf4.0d/egcs-2.91.57/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -D__EXCEPTIONS -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus -Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5) test.cc /usr/users/schopper/local/tmp/cc9zRCyU.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release)
#include "..." search starts here:
#include <...> search starts here:
 /usr/users/schopper/local/include/g++
 /usr/local/include
 /usr/users/schopper/local/alphaev5-dec-osf4.0d/include
 /usr/users/schopper/local/lib/gcc-lib/alphaev5-dec-osf4.0d/egcs-2.91.57/include
 /usr/include
End of search list.
 /usr/users/schopper/local/lib/gcc-lib/alphaev5-dec-osf4.0d/egcs-2.91.57/cc1plus /usr/users/schopper/local/tmp/cc9zRCyU.ii -quiet -dumpbase test.cc -version -o /usr/users/schopper/local/tmp/cciD4oR2.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release) (alphaev5-dec-osf4.0d) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
test.cc: In function `int main()':
test.cc:14: request for member `__ct' in `*{anon}', which is of non-aggregate type `double'
 

This "bug" is especially problematic, if one tries to write
a template function with 

template <class T>
test (T x, T init=T()) { 
//...

T*  bla = new T[20] (init);
//...
};

in it, because one can't know what type the user will chose. 

Most interesting is the fact, that this error has occured after
installing this revision. In a previous one (sorry don't know which)
there was no such problem.


I don't know if this is a bug or anything else.

 Ruediger Schopper


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