Ticket #6132 (closed Bugs: fixed)

Opened 5 years ago

Last modified 5 years ago

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


Change History

comment:1 Changed 5 years ago by apolukhin

  • Status changed from new to closed
  • Resolution set to fixed

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


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

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

Note: See TracTickets for help on using tickets.