jeudi 30 novembre 2017

Can the "main" function be declared with the "noexcept" specifier?

Is the following code valid in C++?

int main() noexcept
{
}

Both clang++ 3.8.0 and g++ 7.2.0 compile it fine (with -std=c++14 -O0 -Wall -Wextra -Werror -pedantic-errors compilation flags).

Is it allowed to use complex conditions (e.g. including noexcept operator) in the noexcept specification of the main function?

And what about C++17? As I know noexcept specifier becomes the part of the function type in this revision of the standard.

Aucun commentaire:

Enregistrer un commentaire