------- Comment #2 from redi at gcc dot gnu dot org 2010-03-20 01:03 ------- Hmm, on second thoughts... Technically that program has undefined behaviour because p does not have a value that comes from a previous new expression, however this variation is not undefined as long as Foo has a trivial destructor, and f returns a pointer to an array of Foo:
class Foo; Foo* f(); int main() { Foo* p = f(); delete [] p; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452