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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This happens on Linux too. The issue is that per C++11 (see 18.6) operator new
is declared in <new> as:

  void* operator new(size_t mem);                  (1)

and as such is internally pre-declared in decl.c:cxx_init_decl_processing.
Then, if I understand correctly, when the parser sees in user code:

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

it thinks, Ok the user is just redeclaring (1), it simply ignores the exception
specifier. Then the additional declaration in user code is seen inconsistent
with the former one (it becomes clear that the exception specifier was dropped
the first time).

We (used to) have a completely similar, dual, issue in C++98 for this user
code:

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

and I'm not sure whether and how we want to do better.

Note that changing in C++11 the user code to:

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

is perfectly fine.

Reply via email to