Opened 8 years ago
Closed 7 years ago
#11047 closed Bugs (obsolete)
Valgrind warning "uninitialized variable" with lexical_cast on empty string as target
Reported by: | Owned by: | Antony Polukhin | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | lexical_cast |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | lexical_cast uninitialized variable valgrind | Cc: |
Description
Hello, I have a problem with boost::lexical_cast<int>(aString) when aString is an empty string ("").
In that case, valgrind complains with a warning "uninitialized variable".
Attachments (1)
Change History (5)
by , 8 years ago
Attachment: | Screenshot 2015-02-18 18.10.16.png added |
---|
comment:1 by , 8 years ago
Component: | None → lexical_cast |
---|---|
Owner: | set to |
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|---|
Status: | new → assigned |
comment:4 by , 7 years ago
Resolution: | → obsolete |
---|---|
Status: | assigned → closed |
Looks like this issue was fixed somewhere between 1.47-1.59.
New code correctly handles empty strings:
- on empty string
m_begin == m_end
- Decrementing `m_end` without dereferencing
- `m_begin > m_end` is `true`, which will prevent the compiler from evaluating the expression further,
false
will be returned. - exception is thrown
Thanks for reporting this issue anyway!
If you need a fix for Boost 1.47, then just replace the line
if ( *end < czero || *end >= czero + 10 || begin > end)
with
if (begin > end || *end < czero || *end >= czero + 10)
Note:
See TracTickets
for help on using tickets.
Hello,
any news on this?