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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> I agree with comment 3 that the current diagnostic is poor:

Oh I missed that.

> 
> #include <new>
> void* operator new(std::size_t mem) throw(std::bad_alloc);
> void* operator new(std::size_t mem) throw(std::bad_alloc);
> 
> 
> g++ -std=c++11  -c new.cc -Wno-deprecated
> new.cc:3:7: error: declaration of ‘void* operator new(std::size_t) throw
> (std::bad_alloc)’ has a different exception specifier
>     3 | void* operator new(std::size_t mem) throw(std::bad_alloc);
>       |       ^~~~~~~~
> new.cc:2:7: note: from previous declaration ‘void* operator new(std::size_t)’
>     2 | void* operator new(std::size_t mem) throw(std::bad_alloc);
>       |       ^~~~~~~~
> 

Reduced testcase for that:
void f(void);
void f(void) throw(int);
void f(void) throw(int);

Noexcept has the same issue:
void g(void);
void g(void) noexcept;
void g(void) noexcept;

I suspect what happens is the following when we merge the two decls we chose
the new decl for the location but we remove the exception specifier/noexcept
(confirmed by swapping the first two decls and seeing the error again).

Reply via email to