I have the following code
#include <tuple>
struct A{
int a;
int b;
};
std::tuple<A,bool> get(){
return {{}, true};
}
With GCC 9.* and GCC 10., everything works fine. But when compiling with GCC 11., it compiles failed with following error message
<source>: In function 'std::tuple<A, bool> get()':
<source>:10:21: error: conversion from '<brace-enclosed initializer list>' to 'std::tuple<A, bool>' is ambiguous
10 | return {{}, true};
| ^
In file included from <source>:2:
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/tuple:1159:9: note: candidate: 'std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&) [with _Alloc = bool; typename std::enable_if<std::_TupleConstraints<std::is_object<_Alloc>::value, _T1, _T2>::__is_implicitly_default_constructible(), bool>::type <anonymous> = true; _T1 = A; _T2 = bool]'
1159 | tuple(allocator_arg_t __tag, const _Alloc& __a)
| ^~~~~
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/tuple:1067:9: note: candidate: 'constexpr std::tuple<_T1, _T2>::tuple(const _T1&, const _T2&) [with bool _Dummy = true; typename std::enable_if<std::_TupleConstraints<_Dummy, _T1, _T2>::__is_implicitly_constructible<const _T1&, const _T2&>(), bool>::type <anonymous> = true; _T1 = A; _T2 = bool]'
1067 | tuple(const _T1& __a1, const _T2& __a2)
| ^~~~~
Compiler returned: 1
I noticed that both candinates exist in every version of GCC. So why would compiling failed in GCC 11? What makes this change.
GCC 10.3: https://godbolt.org/z/dbfv68xcr
GCC 11.3: https://godbolt.org/z/M3M7zesWf
==== UPDATE ====
Actually I understand why this code causes compiling fail. But why do GCC 10.* and its ancestors compile?