This is the mail archive of the gcc@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: Vector new bug ??


Günter Neiß <gneiss@schoenhofer.de> writes:

> Hi,
>
>  I found the following bug:
>
>  Using some templates that uses:
>
>  template<class T>
>  ....
>    t * p = new T[ size ];
>
>
>  Everything works fine, as long as 'size' isn't 0.
>
>  In that case I got an exeption inside 'builin vector new' (shown by
> gdb).

This is indeed a bug:

| When the value of the expression in a direct-new-declarator is zero,
| the allocation function is called to allocate an array with no
| elements.  The pointer returned by the new-expression is non-null.
| [Note: If the library allocation function is called, the pointer
| returned is distinct from the pointer to any other object.  ]

ISO/IEC 14882:1998, 5.3.4(7).


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