![]() |
От: |
rg45
|
|
Дата: | 17.08.25 11:16 | ||
Оценка: | +1 |
R>>#include <iostream>
R>>int x;
R>>int main() {
R>> int y;
R>> std::cout << x << std::endl; // OK
R>> std::cout << y << std::endl; // warning: 'y' is used uninitialized [-Wuninitialized]
R>>} // а где warning no return value ?
R>>
6.9.3.1 main function
5 A return statement ([stmt.return]) in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control flows off the end of the compound-statement of main, the effect is equivalent to a return with operand 0 (see also [except.handle]).
8.7.3 The return statement
2 . . . Otherwise, flowing off the end of a function other than main or a coroutine ([dcl.fct.def.coroutine]) results in undefined behavior.