GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
c++

c++: Implement C++29 P3424R2 deallocation functions ill-formed diagnostic

Implements a C++29 rule making deallocation functions with throwing exception specifications ill-formed.

GCC now diagnostics deallocation functions with throwing exception specifications as ill-formed, implementing the C++29 rule P3424R2. This change affects functions like operator delete and operator delete[]. The compiler now checks for these cases during declaration parsing and instantiation in functions like grokfndecl, maybe_instantiate_noexcept, and cp_parser_class_specifier, with new tests added to verify the diagnostics for both C++29 and earlier standards.

In Details

This commit implements C++29 P3424R2, which states that deallocation functions (operator delete, operator delete[], and their sized variants) which are declared with a throwing exception specification (e.g., noexcept(false)) are ill-formed. The diagnostic is added by introducing maybe_diagnose_deallocation_noexcept_false and calling it from grokfndecl (when processing declarations), maybe_instantiate_noexcept (during template instantiation), and cp_parser_class_specifier (during class definition parsing). Test cases are updated to reflect the expected diagnostics for C++29 and b…

For Context
deallocation function
Functions in C++ responsible for freeing dynamically allocated memory, such as operator delete and operator delete[].
exception specification
A declaration that indicates which exceptions a function might throw. noexcept(false) indicates that the function might throw exceptions.
ill-formed
A construct in the C++ language that violates the language rules and should result in a compile-time error or diagnostic.
C++29
The upcoming revision of the C++ programming language standard, following C++20 and C++23.
Filed Under: c++standard compliancecompiler