https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86346
Bug ID: 86346 Summary: internal compiler error related to duduction guides Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vanyacpp at gmail dot com Target Milestone: --- Here is the code: template<bool> struct bool_constant {}; using true_type = bool_constant<true>; template<typename, typename> constexpr bool is_same_v = false; template<typename T> constexpr bool is_same_v<T, T> = true; template<typename T> struct vector { template<typename U> static constexpr bool v = is_same_v<T, bool> || false; vector(bool_constant<v<T>>, T); // (1) }; template<> struct vector<bool> // (2) { vector(true_type, bool); }; vector v { true_type{}, false }; // (3) The problem is that the deduction guide generated from the constructor (1) refers to a member v of the primary template. At (3) T is then deduced to be bool, but substitution T->bool should never be used for primary template, as there is explicit specialization vector<bool> (2). Clang gives an error on this code "note: candidate template ignored: substitution failure [with T = bool]: cannot reference member of primary template because deduced class template specialization 'vector<bool>' is an explicit specialization". I believe GCC should provide a similar message in this case instead of crashing.