Opened 7 years ago
Closed 6 years ago
#11740 closed Bugs (fixed)
string_ref not working correctly with rvalue of std::string
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | Component: | utility | |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | string_ref | Cc: |
Description
This is currently allowed: boost::string_ref something; something = "temp"; works ok something = std::string("temp"); doesn't work corretly
while it should not be a should only be: boost::string_ref something; something = "temp"; works ok std::string tempStr("temp"); something = tempStr; works ok
Current version is pointing to buffer that is no longer part of any std::string, therefore if you use something like valgrind it will trigger and error.
Attached is a simple patch that prevent this.
Attachments (2)
Change History (3)
by , 7 years ago
by , 7 years ago
Attachment: | decription with formatting.txt added |
---|
Descirption (again) with correct formatting
comment:1 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed w/ a test in 9960d9f395b79ee860e39064cd46961f76d2cb55 Unfortunately, the fix only works in C++11 and later.
proposed patch