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]

Re: BUG with an array of class objects


Alexandre Oliva writes:
 > Philippe Lavoie <lavoie@zeus.genie.uottawa.ca> writes:
 > 
 > >   a = new point[4]() ; 
 > >   a = new point[4](0) ; 
 > >   a = new point[4]((float*)0,0) ; 
 > 
 > Note that this is not ANSI/ISO C++: initializing array types with
 > non-default constructors in new expressions is provided as an
 > extension of g++/egcs, that is warned if compiled with `-pedantic'.
 > Anyway, this problem seems to be fixed in the latest snapshot.
 > 

According to the draft of december 1996, it is an ok construct. i.e go
see

chapter 5
	http://www.cygnus.com/misc/wp/dec96pub/expr.html

section 5.3.4 New

item 14

I copied the pertinent section here and I marked with a star the place
where it says it's a valid construct. 

Did that part of the standar change with the november 1997 edition ? 

Thanks for the reply.

Phil


  A  new-expression  that  creates  an object of type T initializes that
  object as follows:

  --If the new-initializer is omitted:

    --If T is a (possibly cv-qualified) non-POD  class  type  (or  array
      thereof), the object is default-initialized (_dcl.init_).  If T is
      a const-qualified type, the underlying class  type  shall  have  a
      user-declared default constructor.

    --Otherwise,  the object created has indeterminate value.  If T is a
      const-qualified type, or a (possibly cv-qualified) POD class  type
      (or array thereof) containing (directly or indirectly) a member of
      const-qualified type, the program is ill-formed;

  --If the new-initializer is of  the  form  (),  default-initialization

    shall be performed (_dcl.init_);

* --If  the  new-initializer  is of the form expression-list) and T is a
    class type, the appropriate constructor is called, using expression-
    list as the arguments (_dcl.init_);

  --If  the  new-initializer is of the form expression-list) and T is an
    arithmetic, enumeration,  pointer,  or  pointer-to-member  type  and
    expression-list comprises exactly one expression, then the object is
    initialized to the (possibly  converted)  value  of  the  expression
    (_dcl.init_);

  --Otherwise the new-expression is ill-formed.



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