Topic: Defect Report: ambiguity 'matching deallocation function
Author: Alexander Schiemann <aschiem@math.uni-sb.de>
Date: 1999/06/08 Raw View
This is about 5.3.4 [expr.new] paragraph 17-19 (p.80)
If an exception occurs during object initialization in a new-
expression then a 'matching deallocation function' (if unambiguous)
is called. Paragraph 19 defines the matching deallocation function
for placement allocation functions and non-placement ones.
I did not find a definition of 'placement allocation function' that
solves the following ambiguity:
If one declares an allocation function with a 2nd parameter but
supplies a default argument then this function may be called from a
new-expression without placement argument. If we look for a matching
deallocation function should we look for one with a placement argument
or not? I.e. does the term 'placement allocation function' depend
1. on the declaration of the function (disregarding default arguments
used in the call)
2. or on the syntax of the new-expression that calls the allocation
function ?
My favorite answer is 1) but the egcs compiler (versions 1.0.3--1.1.2)
says 2).
Alexander Schiemann aschiem@math.uni-sb.de
>>>>>>>>>>> begin example
#include <iostream.h>
class A{
public:
A()
{throw 5;}
void* operator new(size_t size, double x=3.5)
{cout<<"A::operator new(size_t,double)\n";
return ::operator new(size);}
void operator delete(void* p, double)
{cout<<"A::operator delete(void*,double)\n"
<<" matching operator delete with placement argument\n"
<<" although no explicit placement argument in the\n"
<<" new-expression\n"
<<flush;
::operator delete(p);}
void A::operator delete(void* p)
{cout<<"A::operator delete(void*)\n"
<<" matching non-placement operator delete\n"
<<" for operator new called with default placement argument"
<<endl;
::operator delete(p);}
};
int main()
{try
{new A;}
catch(...){;}
}
<<<<<end example
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]