Modify

Opened 6 years ago

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

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by apolukhin

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

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain nasonov.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.