-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add errors on invalid/missing function return type #8165
Conversation
GCC 10.x seems to have a knack for crashing when a function which is declared to return a value does not. Add a warning, present on all builds, when this is the case. For more info see esp8266#8160 Thanks to @hreintke for the tip
This warning is basically a must-have on the ESPs. Is there a way to treat it as an error? Because that is what it really is on this architecture, returning from non-void function without a return statement. @earlephilhower That said, then looked at your PR, you have already upgraded it to error, correct? Thanks, this will help me with 3rd party PRs to my libraries as well. |
Notice it is not just -W, but -Werror. Turns out gcc can selectively pick warnings to be treated as errors |
@me-no-dev In reference to the now closed discussion about espressif/arduino-esp32#5310, would you see any value in this and get it inserted into the right places, instead of the simple warning, that I am already getting for such misuses ( |
@dok-net I will accept the same change in the ESP32 repo 😄 |
@me-no-dev Before moving over there (sorry ESP8266 guys for talking about ESP32 here), you recently said:
The files were |
just |
@earlephilhower This is from ESP32,
What do you think about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to update tools/platformio-build.py
Arduino/tools/platformio-build.py
Lines 61 to 87 in d313673
CFLAGS=[ | |
"-std=gnu17", | |
"-Wpointer-arith", | |
"-Wno-implicit-function-declaration", | |
"-Wl,-EL", | |
"-fno-inline-functions", | |
"-nostdlib" | |
], | |
CCFLAGS=[ | |
"-Os", # optimize for size | |
"-mlongcalls", | |
"-mtext-section-literals", | |
"-falign-functions=4", | |
"-U__STRICT_ANSI__", | |
"-D_GNU_SOURCE", | |
"-ffunction-sections", | |
"-fdata-sections", | |
"-Wall", | |
"-free", | |
"-fipa-pta" | |
], | |
CXXFLAGS=[ | |
"-fno-rtti", | |
"-std=gnu++17" | |
], |
I guess CCFLAGS is the correct choice, based on underlying build system docs:
https://scons.org/doc/latest/HTML/scons-user/apa.html
CCFLAGS
General options that are passed to the C and C++ compilers.
GCC 10.x seems to have a knack for crashing when a function which is declared
to return a value does not. Add a warning, present on all builds, when this
is the case. For more info see
#8160
Thanks to @hreintke for the tip