https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82632
Bug ID: 82632 Summary: copy deduction candidate erroneously preferred over deduction-guide Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Minimal example courtesy of STL from https://bugs.llvm.org/show_bug.cgi?id=34970: template <typename X, typename Y> struct IsSame { static constexpr bool value = false; }; template <typename Z> struct IsSame<Z, Z> { static constexpr bool value = true; }; template <typename T> struct Optional { template <typename U> Optional(U&&) { } }; template <typename A> Optional(A) -> Optional<A>; int main() { Optional opt(1729); Optional dupe(opt); static_assert(IsSame<decltype(opt), Optional<int>>::value); static_assert(IsSame<decltype(dupe), Optional<int>>::value); static_assert(!IsSame<decltype(dupe), Optional<Optional<int>>>::value); } gcc accepts this code, but dupe should be an Optional<Optional<int>> since the deduction-guide should take precedence over the copy deduction candidate per the ordering in [over.match.best].