https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #9 from Diego Franco ---
Correction/editing of last section of former comment:
...
- init brace does not work for user defined conversion reference WITHOUT static
cast:
A a {};
const std::vector& b {a}; // changed from "auto" to "st
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #8 from Diego Franco ---
So to summarize, these are the main reason why I believe this should be
addressed:
- init brace works for references of any type:
std::vector a {};
std::vector& b {a};
assert(&a == &b); // works
int c {};
i
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #7 from Diego Franco ---
This works:
#include
#include
struct A
{
operator const int&() const
{
return a_;
}
int a_;
};
int main()
{
A a {};
const auto& b1 {static_cast(a)};
const int& b2 {a};
assert(&a.a_
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #6 from Diego Franco ---
Also the brace initialization works with primitive types for the code I posted
in the first place. That's definitely a code smell.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #4 from Diego Franco ---
> It's not implementation defined, but I think all implementations are required
> to do what GCC 8 does (and other compilers agree).
It worked on linaro 7.4.1 gcc with c++17, gcc 7.1.0 with c++17 only.
> If
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91742
--- Comment #1 from Diego ---
The code does work when changing std::vector for any primitive types, i.e.
int.
++
Assignee: unassigned at gcc dot gnu.org
Reporter: di...@franco-technologies.com
Target Milestone: ---
The following code does not work as intended:
//Example-
#include
#include
struct A
{
operator const std::vector&() const
{
return a_;
}
std::vecto