Title
Change in behavior for noexcept main
Status
open
Section
6.10.3.1 [basic.start.main]
Submitter
Jiang An

Created on 2025-08-15.00:00:00 last changed yesterday

Messages

Date: 2025-09-12.22:42:26

Suggested resolution:

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

... An implementation shall allow both
  • a "optionally noexcept function of () returning int" and
  • a "optionally noexcept function of (int, pointer to pointer to char) returning int"
as the type of main (9.3.4.6 [dcl.fct]). ...
Date: 2025-08-15.00:00:00

(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.

History
Date User Action Args
2025-09-12 22:42:26adminsetmessages: + msg8091
2025-08-15 00:00:00admincreate