From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30470 invoked by alias); 17 Jun 2013 09:45:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30434 invoked by uid 48); 17 Jun 2013 09:45:11 -0000 From: "paolo.carlini at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57632] Operator new overloads with stdc++11 enabled looses exception specifier (MacOsX) Date: Mon, 17 Jun 2013 09:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: paolo.carlini at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg00907.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57632 Paolo Carlini changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #1 from Paolo Carlini --- This happens on Linux too. The issue is that per C++11 (see 18.6) operator new is declared in 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.