https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80438

Tony E Lewis <TonyELewis at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |TonyELewis at hotmail dot com

--- Comment #1 from Tony E Lewis <TonyELewis at hotmail dot com> ---
Here are the notes I wrote before I spotted I was about to file a duplicate of
Vittorio's report...


[C++17] constructor unexpectedly preferred over deduction guide in CTAD

Compiling the following under `-std=c++17` :


#include <type_traits>

template <typename...>
struct x {
    template <typename... Ts> x(const Ts &...) {}
};

template <typename... Ts> x(const Ts &...) -> x<Ts...>;

static_assert(   std::is_same_v< decltype( x{ 0 } ), x<int> > );
static_assert( ! std::is_same_v< decltype( x{ 0 } ), x<   > > );


...I see the two static_assert statements failing under GCC, implying that `x{
0 }` is of type `x<>`, rather than `x<int>` as I would expect. These two
static_assert statements pass under Clang.


I would expect `x<int>` because I would expect the deduction guide to take
precedence over the constructor in determining the type of the expression `x{ 0
}`. AFAIU, this is what's meant by the point in [over.match.best] in the
standard that says F1 is "better" than F2 if: 

> [...] F1 is generated from a deduction-guide [...] and F2 is not [...]

(from C++17 draft n4659.pdf and from working draft
http://eel.is/c++draft/over.match.best )

I'm seeing this on the current trunk build of GCC on Godbolt (g++ 9.0.0
20181225 (experimental)).

Reply via email to