-
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: fix concatenation from flash #6368
Conversation
@earlephilhower I'm not sure if |
The class structure in @d-a-v, how about working around the issue by adding a "memmove_P" to the standard newlib functions instead? It's trivial:
Yes, it crashes if you try to memmove with flash destination, but that's the correct behavior. :) Something similar is being done for strlen() due to GCC having some silent optimizations that call it. Then this fix becomes a |
I don/t want to sound pushy or something, but can we have a intermittent fix for master in the meantime? ;-) My firmware depends on I'm surprised nobody else complained about += being broken, yet. |
Thanks! |
Adding just PSTR() to a string and hoping things work is very bad. Never do this unless you really know what you do. I commented on #6367 and I think you should actually revert this code change. |
It's not about hope&magic :) The fix can be done, but what @earlephilhower proposed in #6368 (comment) is better than what I proposed. |
And ... the fix for the user's problem is for him to correctly use flash strings: to use F("sss") and NOT PSTR("xyz") .
@d-a-v : That fix is also using some strange hardcoded number (0x40000000). Imagine people doing these:
I hope you see now how bad it is to use PSTR() randomly and why promoting that kind of use is bad. A better change - although it can also probably break things and might not be complete either, is to do changes in pgmspace.h:
Or just redirect people having problems to the docs I linked. |
This is specific to esp8266. All data above this address are " About the documentation on the arduino side, you are right and libraries need to use the correct macros when it comes to use PROGMEM data. We usually redirect users to the docs you mentionned when such issue occurs. Again, #6367 is about restoring something which was working in the past (I think, but anyway internally useful) and is not a good use case to show to users. |
@d-a-v Of course I figured out what's with the 0x40... value. But I would recommend creating a real constant in some header with it. Somehow I think it might be useful in more places.
|
What about you create a pull request with your proposed recommended changes ? |
memmove_P is now in libc, so use it to allow WString to handle F() pointers without errors. Supercedes esp8266#6368 Fixes esp8266#6384
fixes #6367