Opened 6 years ago

Closed 6 years ago

#6132 closed Bugs (fixed)

lexical_cast with Source = void* broken in 1.48.0

Reported by: jk_boost_bug@… Owned by: nasonov
Milestone: To Be Determined Component: lexical_cast
Version: Boost 1.48.0 Severity: Regression
Keywords: Cc:


Since 1.48.0, lexical_cast<string> does not compile anymore, where the Source type is void*. This worked fine in 1.47.0 and before.


#include <string>
#include <iostream>
#include <boost/lexical_cast.hpp>

int main(int argc, const char **argv) {
  int x = 0;
  void *ptr = &x;

  std::string s = boost::lexical_cast<std::string>(ptr);

  std::cout << s << std::endl;
  return 0;

Compiler output:

..../boost/lexical_cast.hpp: In static member function ‘static Target boost::detail::lexical_cast_do_cast<Target, Source>::lexical_cast_impl(const Source&) [with Target = std::string, Source = void*]’:
..../boost/lexical_cast.hpp:1916:   instantiated from ‘Target boost::lexical_cast(const Source&) [with Target = std::string, Source = void*]’
test.cpp:9:   instantiated from here
.../boost/lexical_cast.hpp:1742: error: invalid application of ‘sizeof’ to a void type

The problem seems to be that sizeof(void) is called in the calculation of 'const bool requires_stringbuf' (lexical_cast.hpp:1728).

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by Antony Polukhin

Resolution: fixed
Status: newclosed

(In [76305]) Fixes #6132 Fixes #6182

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain nasonov.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.