-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
6.13.0 broken for non-copy-constructable String types #1126
Comments
It's used to access counted strings stored in flash memory by casting as a reference. i.e. I am looking at a revision which uses FlashString a simple wrapper class, and if that make it as easy (or easier) to use then the problem goes away. |
@bblanchon Just to let you know I've fixed the incompatibility problem by adding copy constructor support. Inspired by your own libraries, I've created FlashString. Thank you for setting the standard! |
With commit 6da6f92 both ElementProxy and MemberProxy take copies of the
TString argument instead of taking a reference.
This breaks existing code which depends upon the referencing behaviour, and also has performance/efficiency implications.
The fault addressed by the above commit is briefly outlined in #1120, caused by a
dangling reference
. To clarify, this is where the ElementProxy/MemberProxy take a reference to a temporary object (e.g. arduino String) which the compiler optimises out before the reference is used. This leads to unpredictable behaviour, so clearly taking proper copies is the safest (default) behaviour.However, I have a custom
FlashString
class (with adapter) which is not copy-constructible and so now no longer works as intended.Here are the details:
I've been unable to find a workable solution without modifying ArduinoJson so I'll propose that and see where we go.
It feels like there's room for improvement here. Can we detect when it's safe to take a reference, and do that when possible?
The text was updated successfully, but these errors were encountered: