From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7CDD13857C5B; Mon, 21 Sep 2020 05:52:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CDD13857C5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600667560; bh=5nBumWhj329wRQ16fpoVJzK74lLTVMLuns6jNTirNYk=; h=From:To:Subject:Date:From; b=E9iQZFr7Uf7Ansz+J/ELKzkg834z3iYAue/vQfIgu7djxcRRoI5LfHNAk06HKI3Vg sqhblaHJPwoCotKLpFqlgyq9E2f4re5cuUoMLal9lBqKeMdiZ8nYewepDDtCzFs1hd VCPZOH1ri5h2rWO5p7oNQM9tJwO2QdNckj4kZuMk= From: "Darrell.Wright at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97134] New: partial specialization not more specialized when using CNTTP Date: Mon, 21 Sep 2020 05:52:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Darrell.Wright at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2020 05:52:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97134 Bug ID: 97134 Summary: partial specialization not more specialized when using CNTTP Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Darrell.Wright at gmail dot com Target Milestone: --- g++, tried trunk on CE along with 10.2 and 10.1 will say the following code= is not more specialized when JSONNAMETYPE is a CNTTP(json_name). When it's a NTTP(char const *) it is ok with it. The code works in MSVC's C++20 mode. https://godbolt.org/z/7v4nx5 #include #include #include #include template struct json_name { static_assert(N > 0); char const m_data[N]{}; private: template constexpr json_name(char const (&ptr)[N], std::index_sequence) : m_data{ptr[Is]...} {} public: constexpr json_name(char const (&ptr)[N]) : json_name(ptr, std::make_index_sequence{}) {} // Needed for copy_to_iterator [[nodiscard]] constexpr char const *begin() const { return m_data; } // Needed for copy_to_iterator [[nodiscard]] constexpr char const *end() const { return m_data + static_cast(size()); } [[nodiscard]] static constexpr std::size_t size() noexcept { return N - 1= ; } template constexpr bool operator=3D=3D(json_name const &rhs) const { if (N !=3D M) { return false; } for (std::size_t n =3D 0; n < N; ++n) { if (m_data[n] !=3D rhs.m_data[n]) { return false; } } return true; } constexpr operator std::string_view() const { return std::string_view(m_data, size()); } }; template json_name(Chars...) -> json_name; template json_name(char const (&)[N]) -> json_name; #ifdef USE_CNTTP #define JSONNAMETYPE json_name #else #define JSONNAMETYPE char const * #endif template struct X : std::false_type { static constexpr std::string_view name =3D Name; }; template struct X : std::true_type { static constexpr std::string_view name =3D Name; }; int main() { static constexpr char const A[] =3D "A";=20=20 static constexpr char const B[] =3D "B";=20=20 auto a =3D X::name; auto b =3D X::name; std::cout << a << b << '\n'; }=