Skip to content

[basic.start.main] Adding noexcept to main may be rejected now #752

@frederick-vs-ja

Description

@frederick-vs-ja

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [basic.start.main]

Link to reflector thread (if any):

Issue description:

In C++11/14, noexcept wasn't a part of a function type, so an implementation was required to accept int main() noexcept {} or int main(int, char**) noexcept {}.

In C++17 (via P0012R1), noexcept was made a part of type system, while the restriction of type of main wasn't correspondingly updated. As a result, an implementation may reject a main function that is noexcept, which possibly breaks some programs.

Per this example, MSVC, GCC, and Clang still support adding noexcept to main, while EDG (and deprecated ICC) diagnoses it. However, EDG (and ICC) also emit such diagnostic in C++14 mode, which isn't so conforming.

If it is intended to support adding noexcept to main, perhaps we should change [basic.start.main] p2 correspondingly. Otherwise, I think we should add an entry to Annex C.

Suggested resolution:

(for supporting adding noexcept)

Modify [basic.start.main] as indicated.

[...]

  • (2.1) aan optionally noexcept function of () returning int and
  • (2.2) aan optionally noexcept function of (int, pointer to pointer to char) returning int

[...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions