-
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
WString: remove operator==(const __FlashStringHelper*) #8569
Conversation
We don't want to overload comparisons though? Check out operator calls you are proposing with older versions, or the esp32 Core, or even the ArduinoCore API test suite.
Main ambiguity comes from fpstr vs. const char, that wasn't there in the older Core versions. Yes, this is another case of older code breaking, but I'd rather WiFiManager fixes this issue b/c we add another heap of issues on top.
|
Comparison with `P("test")` will use an implicit temporary `String(P("test"))` and restore warning-less & correct comparison with NULL through `==(const char*)` overload.
Removing |
note that #8106 used this as a way to shrink ESPeasy binary size due to a temporary String obj |
True. |
With this last commit, |
cores/esp8266/WString.h
Outdated
return length() == 0; | ||
} | ||
[[deprecated("use nullptr instead of NULL")]] | ||
bool operator ==(decltype(NULL)) const { |
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.
just note that the trade-off is someone will write obj == 5;
returning false positive :)
(...and iirc ide default to 'no warnings', which does not help...)
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.
Given that std::nullptr_t
is a distinguishable type, I tried the same with decltype(NULL)
.
Despite the existence of the __null
internal keyword and the __sentinel__
attribute, I currently cannot manage NULL
separately from int/long.
I reverted: ==(FlashStringHelper*)
is removed again.
We still have this:
#define NULL nullptr
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.
I think they refer to some old version of GCC (pre 4.6?) with the __null
stuff.
And I'd like to find some examples of #define NULL std::nullptr
, as it seems like something for the system header to have
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.
The only one I could find that is installed on my workstation and probably rarely used(*).
(*)given std::
and using
are both lacking
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.
So we could've had this
https://github.com/gcc-mirror/gcc/blob/1815462a6e53465c404f8a5f6116891492d4b50b/gcc/ginclude/stddef.h#L396
But, newlib overrides it
https://github.com/earlephilhower/newlib-xtensa/blob/ebc967552ce827f21fc579fd8c437037c1b472ab/newlib/libc/include/stdlib.h#L60-L62
edit: ...need to check the preprocessor chain, though, but I would guess it overrides it
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, glibc code requesting it
https://code.woboq.org/userspace/glibc/stdlib/stdlib.h.html#_M/__need_NULL
This change proposal ends up with simply removing |
renamed |
fixes https://gitter.im/esp8266/Arduino?at=627fee0ed30b6b44ebeaa803
@bwjohns4 @JAndrassy
there will still be a warning, because.nullptr
should be used instead ofNULL