No warnings about functions with missing return directives

squire
Posts: 7
Joined: Tue Oct 15, 2024 8:25 pm

No warnings about functions with missing return directives

Postby squire » Fri Aug 15, 2025 4:21 pm

All the other build systems I've used will fail to compile if a function has a return type but not all code paths lead to a return statement, except for IDF. In IDF, functions build just fine and usually I find the bug in the form of a stack corruption; though in the following case, omitting the return statement causes the loop to run infinitely.

Code: Select all

    int example()
    {
        for (int i = 0; i < 32; i++)
        {
            printf("i = %i\n", i);
        }
    }
Is this expected behaviour? I feel like this is an issue with the build system or compiler. This only happens when building C++ files. If I try the same thing in a C file, the compiler throws the following error:
error: control reaches end of non-void function [-Werror=return-type]
Assuming this is a bug, where should I make the report?

adokitkat
Espressif staff
Espressif staff
Posts: 77
Joined: Thu Jun 22, 2023 12:50 pm

Re: No warnings about functions with missing return directives

Postby adokitkat » Mon Aug 25, 2025 11:58 am

Hello. Could you please report it here? https://github.com/espressif/esp-idf/issues

Very much appreciated, thank you.

Who is online

Users browsing this forum: No registered users and 1 guest