[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2021-12-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=97220

--- Comment #8 from Andrew Pinski  ---
PR 97220 looks similar and might be a dup of this bug.

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2019-01-14 Thread ensadc at mailnesia dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

--- Comment #7 from ensadc at mailnesia dot com ---
(In reply to Zhihao Yuan from comment #6)
> Here is a possibly related case:
> 
> [...]

I think this is a different bug. GCC thinks the implicitly-deleted move
assignment operator `pair& pair::operator=(pair&&)` is a
candidate for the assignment, which causes ambiguity with
`operator=(value_type&&)` (where value_type = pair). But as part of
resolution of CWG 1402, [class.copy.assign] specifies that "A defaulted move
assignment operator that is defined as deleted is ignored by overload
resolution".

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2019-01-12 Thread lichray at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

Zhihao Yuan  changed:

   What|Removed |Added

 CC||lichray at gmail dot com

--- Comment #6 from Zhihao Yuan  ---
Here is a possibly related case:

#include 

template 
struct pair
{
using value_type = pair>;

T a, b;

constexpr pair& operator=(value_type const& other)
{
a = other.a;
b = other.b;
return *this;
}

constexpr pair& operator=(value_type&& other)
{
a = std::move(other.a);
b = std::move(other.b);
return *this;
}
};

template 
constexpr pair tie(T& a, T& b) noexcept
{
return { a, b };
}

int main()
{
int a = 3;
int b = 5;
tie(a, b) = { b, a % b };  // works
tie(a, b) = { b, a };  // wat
}

Error messages are very similar https://godbolt.org/z/4FSeOO.

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2019-01-07 Thread ensadc at mailnesia dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

ensadc at mailnesia dot com changed:

   What|Removed |Added

 CC||ensadc at mailnesia dot com

--- Comment #5 from ensadc at mailnesia dot com ---
This is also ambiguous and seems to have the same cause (i.e. overload
resolution accepts list-initialization that calls explicit constructor when
forming the implicit conversion sequence):

template
struct in_place_type_t { explicit in_place_type_t() = default; };

struct A { };

int f(A);
int f(in_place_type_t);

int x = f({});

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2018-10-15 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #4 from Marek Polacek  ---
Thanks, this sounds interesting.

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2018-10-11 Thread raphael.kubo.da.costa at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

Raphael Kubo da Costa  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #3 from Raphael Kubo da Costa  ---
+mpolacek in case he'd like to take a look. This is still reproducible with
trunk.

[Bug c++/84849] Ambiguous resolution of braze initializer list to a class with explicit constructors

2018-03-13 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849

Jonathan Wakely  changed:

   What|Removed |Added

Summary|Ambiguous resolution of |Ambiguous resolution of
   |braze initializer list to a |braze initializer list to a
   |class with explicit |class with explicit
   |copy/move constructors  |constructors

--- Comment #2 from Jonathan Wakely  ---
Further reduced:


struct X {
  X(int) { }
};

struct Foo {
  explicit Foo(const X&);
  explicit Foo(X&&) { }
};

int main() {
  Foo v({1});
}


vs.cc: In function 'int main()':
vs.cc:11:12: error: call of overloaded 'Foo()'
is ambiguous
   Foo v({1});
^
vs.cc:7:12: note: candidate: 'Foo::Foo(X&&)'
   explicit Foo(X&&) { }
^~~
vs.cc:6:12: note: candidate: 'Foo::Foo(const X&)'
   explicit Foo(const X&);
^~~
vs.cc:5:8: note: candidate: 'constexpr Foo::Foo(const Foo&)'
 struct Foo {
^~~
vs.cc:5:8: note: candidate: 'constexpr Foo::Foo(Foo&&)'