-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Remove warnings when NDEBUG build option used #4066
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
Conversation
When building using the new NDEBUG option recently added, the assert() macro is defined to nothing. This leaves a few variables unused in the WiFi stack causing compiler warnings. Add in empty casts to remove these warnings. Does not affect actual assert use when NDEBUG is not defined.
This doesn't look right to me. I think the definition of #ifdef NDEBUG /* required by ANSI standard */
# define assert(__e) ((void) sizeof(__e))
#else
# define assert(__e) ((__e) ? (void)0 : __assert_func (PSTR(__FILE__), __LINE__, \
__ASSERT_FUNC, #__e))
// etc in which case these (void) casts will not be required. Edit: also, perhaps we can put |
Howdy, @igrr The existing macro has the same behavior as my native x86_64 gcc 5.4, which throws the warning on unused params when -NDEBUG is defined:
Do you really want to change the assert() behavior just for the ESP8266 compiler? I'm fine doing the change and updating the PR to only change GCC SDK files, but I have a sinking sensation that this would cause weird stuff in other cases. I could have sworn I tried and failed to get #__e into PMEM when I submitted the original asser() patch a while back, but after checking right now it seems to compile fine. I'll test the actual assert_func() to make sure it runs OK and then update the patch. Given the standard gcc behavior above, what're your thoughts? Still want to update the assert() macro instead of the 2 spots (in the entire IDE/SDK/Arduino std. libs) where there's a problem and values actually aren't checked w/o the assert? Thx |
It turns out that the __e bit is completely ignored in the current __assert_func! It's a simple addition to add it in and update the panic() stuff to detect an assert and print the condition as well as file/line. ...snip...
|
The condition that failed was not being printed in the Panic line, and was in fact completely thrown away. Now print out that an assertion failed and show the condition on a failed assert(). >Panic <file>:<line> <function>: Assertion '<condition>' failed. > >ctx: cont >sp: 3fff0240 end: 3fff0410 offset: 01a0 >>>stack>>> ....
We have been using such method in esp32 sdk for a while and have not seen any odd behavior. |
Closing this due to some GIT troubles. Cleaned up, warning fix only (no core changes) in #4196. |
When building using the new NDEBUG option recently added, the assert() macro is defined to nothing. This leaves a few variables unused in the WiFi stack causing compiler warnings. Add in empty casts to remove these warnings. Does not affect actual assert use when NDEBUG is not defined.