[Bug c++/35110] New: operator new may not be declared within a namespace

gilad at odinak dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 6 18:49:00 GMT 2008


the below code snippet compiles using gcc 3.3.1 but fails to compile with gcc
4.1.1 giving the error

error: ‘void* my_alloc::operator new(size_t, char*, int)’ may not be declared
within a namespace

----- namespace_operator_new.cpp ----------------

#include <new>
using std::bad_alloc;
using std::nothrow_t;

namespace my_alloc {

void * operator new(size_t s, char *file, int line) throw (bad_alloc);
void* operator new[](size_t s, char *file, int line) throw(bad_alloc);
void operator delete(void *p) throw();
void operator delete[](void *p) throw();
}

using namespace my_alloc;

------------------------------------------------------

compiled with
 gcc -g -O2 -Wno-deprecated -Wall -Werror  -c namespace_operator_new.cpp


-- 
           Summary: operator new may not be declared within a namespace
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gilad at odinak dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35110



More information about the Gcc-bugs mailing list