Opened 11 years ago

Closed 11 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:

Description

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.

Example:

#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).

Change History (1)

comment:1 by Antony Polukhin, 11 years ago

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.