Opened 18 years ago

Closed 17 years ago

#343 closed Bugs (Fixed)

Swapped source and target in exception

Reported by: zigmar Owned by: kevlin
Milestone: Component: lexical_cast
Version: None Severity:
Keywords: Cc:

Description

When lexical_cast<> throws exception, the source and 
target parameters are swapped (source_type() return 
target and wise versa).

The reason, that when exception is thrown, the 
parameters to exception's contructor passed in wrong 
order.
The line 190 in "boost/lexical_cast.hpp" reads:
      throw_exception(bad_lexical_cast(typeid(Target), 
typeid(Source)));

instead of:
      throw_exception(bad_lexical_cast(typeid(Source),
typeid(Target)));

(the constructor's first parameter is the type id of the 
source)

Boost Version: 1.32.0

Change History (2)

comment:1 by tslettebo, 18 years ago

Logged In: YES 
user_id=516536

This has been fixed, and will be committed soon among with 
some other fixes: Using source value as "3 " didn't used to 
throw but " 3" did. Now, both throws. Also, there's been a 
suggestion to let lexical_cast use const reference, rather 
than pass by value: This requires some changes to 
lexical_cast, as it doesn't work with const reference as it is.

comment:2 by kevlin, 17 years ago

Status: assignedclosed
Note: See TracTickets for help on using tickets.