Modify

Opened 7 months ago

Closed 2 months ago

#12615 closed Bugs (fixed)

any_cast should use addressof instead of operator &

Reported by: vishalshetye@… Owned by: apolukhin
Milestone: Boost 1.64.0 Component: any
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

Please see attached test.cpp file for sample code. I have included compiler errors in the form of comments in the same.

If a class has overloaded operator & then any_cast (which uses & itself) results in following type of compilation error.

any.hpp:246:16: error: cannot initialize return object of type 'ExampleClass<int> *'
with an rvalue of type 'const int **'

I think fix is to replace use of & operator with std::addressof. I have attached diff of changes to any.hpp which worked with clang++.

Attachments (2)

test.cpp (1.3 KB) - added by vishalshetye@… 7 months ago.
sample code
any_patch.txt (1.3 KB) - added by vishalshetye@… 7 months ago.
sample patch

Download all attachments as: .zip

Change History (6)

Changed 7 months ago by vishalshetye@…

sample code

Changed 7 months ago by vishalshetye@…

sample patch

comment:1 Changed 6 months ago by apolukhin

  • Owner changed from nasonov to apolukhin
  • Status changed from new to assigned

comment:2 Changed 6 months ago by apolukhin

Fixed in develop branch 7260f203. Will be merged into the master branche after the tests pass.

comment:3 Changed 5 months ago by apolukhin

  • Milestone changed from To Be Determined to Boost 1.64.0

comment:4 Changed 2 months ago by apolukhin

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain apolukhin.
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.