gcc bug
Mumit Khan
khan@xraylith.wisc.EDU
Wed Jun 30 23:07:00 GMT 1999
"K. Haley" <khaley@bigfoot.com> writes:
> This code compiles under Borland and MS compilers. GCC however, can't seem
> to find the proper new. I've tried egcs 1.1.2 and the prerelease snapshot
> of GCC 2.95.
>
>
> #include <new.h>
>
> int main()
> {
> return 0;
> }
>
> class foo
> {
> public:
> foo(){;};
> };
>
> namespace OWL {
> template <class A> class TMMemStack{
> public:
>
> TMMemStack( );
> void* Allocate( size_t );
>
> private:
> size_t CurLoc;
> };
> template <class A> inline void* operator new( size_t sz, TMMemStack<A>& m )
> {
> return m.Allocate( sz );
> }
>
> void f()
> {
> foo *i;
> i=new foo; <<<<< HERE
> }
> };
> ---
Though ill-formed according to 3.7.3.1 "ill-formed if an allocation
function is declared in a namespace scope other than the global
scope ...", gcc's diagnostic can definitely stand an improvement.
It essentially quits with the following message when it hits the line
marked with <<<< HERE.:
new-bug.cc: In function `void OWL::f()':
new-bug.cc:46: no matching function for call to `operator new (int)'
Regards,
Mumit
More information about the Gcc-bugs
mailing list