https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
Bug ID: 91742
Summary: User defined conversion references
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
The following code does not work as intended:
//----Example-----
#include <vector>
#include <cassert>
struct A
{
operator const std::vector<int>&() const
{
return a_;
}
std::vector<int> a_;
};
int main()
{
A a {};
const auto& b1 {static_cast<const std::vector<int>&>(a)};
const std::vector<int>& b2 {a};
assert(&a.a_ == &b1);
assert(&b1 == &b2); // does not work with gcc 8.3.0 any standard
// works with gcc 7.1.0 with c++17 only
}
//----End of example-----
I read through the c++17 standard and did not find any information about this
behavior being implementation defined.
Diego