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

            Bug ID: 57632
           Summary: Operator new overloads with stdc++11 enabled looses
                    exception specifier (MacOsX)
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b...@odd-e.com

G++ on MacOsX acts different when enabling the new c++11 related to operator
new overloads. If I compile the following code:

#include "stdlib.h"
#include <new>

void* operator new(size_t mem) throw(std::bad_alloc);
void* operator new(size_t mem) throw(std::bad_alloc);

Then when compiling g++ new.cpp, it compiles fine.
But when I compile g++ -std=c++11 new.cpp, then it results in this error:

new.cpp:6:52: error: declaration of ‘void* operator new(size_t) throw
(std::bad_alloc)’ has a different exception specifier
 void* operator new(size_t mem) throw(std::bad_alloc);
                                                    ^
new.cpp:5:7: error: from previous declaration ‘void* operator new(std::size_t)’
 void* operator new(size_t mem) throw(std::bad_alloc);
       ^
------------

I've not been able to replicate this under linux and digging into it a bit, it
seems to relate to the c++config.h definitions of _GLIBCXX_THROW.

Reply via email to