Opened 6 years ago

Closed 6 years ago

#12615 closed Bugs (fixed)

any_cast should use addressof instead of operator &

Reported by: vishalshetye@… Owned by: Antony Polukhin
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@… 6 years ago.
sample code
any_patch.txt (1.3 KB ) - added by vishalshetye@… 6 years ago.
sample patch

Download all attachments as: .zip

Change History (6)

by vishalshetye@…, 6 years ago

Attachment: test.cpp added

sample code

by vishalshetye@…, 6 years ago

Attachment: any_patch.txt added

sample patch

comment:1 by Antony Polukhin, 6 years ago

Owner: changed from nasonov to Antony Polukhin
Status: newassigned

comment:2 by Antony Polukhin, 6 years ago

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

comment:3 by Antony Polukhin, 6 years ago

Milestone: To Be DeterminedBoost 1.64.0

comment:4 by Antony Polukhin, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.