Skip to content
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: c_str() returns null pointer after move #7611

Merged
merged 3 commits into from
Sep 27, 2020

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Sep 25, 2020

target = std::move(source) does not reset source's buffer pointer back to the sso
#7553 fixes this behaviour

Added as a separate test, perhaps it could go into the existing SSO

edit: failing, as intended:
https://github.com/esp8266/Arduino/pull/7611/checks?check_run_id=1166504473#step:4:2364

-------------------------------------------------------------------------------
core/test_string.cpp:22
...............................................................................

core/test_string.cpp:30: FAILED:
  REQUIRE( origin.c_str() != nullptr )
with expansion:
  {null string} != nullptr

target = std::move(source) does not reset buffer pointer back to the sso
Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a patch that fixes this to the PR? I guess it was only discovered when the noexcept was added, allowing GCC to actually use the move method?

mcspr and others added 2 commits September 27, 2020 05:59
based on the esp8266#7553 without isSSO -> isHeap rename and inline optimizations
additionally, remove useless pre-c++11 preprocessor checks

Co-authored-by: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
@mcspr
Copy link
Collaborator Author

mcspr commented Sep 27, 2020

Can you add a patch that fixes this to the PR?

Done as 7ce820a
Although, I also could rebase with --author=... rewrite of the git history and co-authred-by: $myself instead, since I repeat the existing patch almost 1-to-1

I guess it was only discovered when the noexcept was added, allowing GCC to actually use the move method?

Exactly. Which I noticed when running tests for the library assigning the existing object throughout the loop and moving it elsewhere periodically

@mcspr mcspr changed the title (test) WString: c_str() returns null pointer after move WString: c_str() returns null pointer after move Sep 27, 2020
Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@earlephilhower earlephilhower merged commit cc042b9 into esp8266:master Sep 27, 2020
@mcspr mcspr deleted the patch-2 branch September 27, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants