This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-09-28


3060. Change in behavior for noexcept main

Section: 6.10.3.1  [basic.start.main]     Status: open     Submitter: Jiang An     Date: 2025-08-15

(From submission #752.)

Consider:

  int main() noexcept {}

Prior to P0012R1 (C++17), this was allowed, because noexcept was not part of a function type. This is now ill-formed, because such a main function is not of one of the types allowed in 6.10.3.1 [basic.start.main] paragraph 2.

This needs an Annex C entry or a relaxation of the rules. Note that the presence or absence of noexcept does not change behavior, because an exception leaving main calls std::terminate either way, and main cannot be named in expressions.

Suggested resolution:

Change in 6.10.3.1 [basic.start.main] paragraph 2 as follows:

... An implementation shall allow both as the type of main (9.3.4.6 [dcl.fct]). ...