From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0F193A5405D; Fri, 6 Nov 2020 09:03:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0F193A5405D From: "markus.boeck02 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97740] New: Weird error message about accessing a private member of my own class inside of std::string_view inside of constexpr Date: Fri, 06 Nov 2020 09:03:24 +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: markus.boeck02 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 attachments.created 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: Fri, 06 Nov 2020 09:03:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97740 Bug ID: 97740 Summary: Weird error message about accessing a private member of my own class inside of std::string_view inside of constexpr Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: markus.boeck02 at gmail dot com Target Milestone: --- Created attachment 49513 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49513&action=3Dedit Reproduction of the bug. Simply compile with -std=3Dc++17 I want to apologize for the code you are about to see already. I am one of those people who likes to constexpr and templates at times. In one of my re= cent code that does some constexpr string parsing and validation I encountered a very very weird error message: /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/string_view: In instantiation of 'cld::detail::CommandLine::parseOptions, {detail::INCLUDESbind0, std::in_place_type > >}>:: [with auto:7 =3D {const std::pair, std::in_place_type_t > > >&}]': /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/type_traits:2506:26:= =20=20 required by substitution of 'template static std::__result_of_success()((declval<_Args>)()...)), std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =3D cld::detail::CommandLine::parseOptions, {detail::INCLUDESbind0, std::in_place_type > >}>::; _Args =3D {const std::pair, std::in_place_type_t > > >&}]' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/type_traits:2517:55:= =20=20 required from 'struct std::__result_of_impl, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&>' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/type_traits:138:12:=20= =20 recursively required by substitution of 'template struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t > [with _Result =3D std::__invoke_result, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&>; _Ret =3D void]' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/type_traits:138:12:=20= =20 required from 'struct std::__and_, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&>, void, true, void>, std::__call_is_nothrow, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&>, cld::detail::CommandLine::parseOptions, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&> >' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/type_traits:2979:12:= =20=20 required from 'struct std::is_nothrow_invocable, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::pair, std::in_place_type_t > > >&>' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/tuple:1715:37: requi= red from 'constexpr const bool std::__unpack_std_tuple struct std::is_nothrow_invocable, cld::detail::CommandLine::parseOptions, {detail::INCLUDESbind0, std::in_place_type > >}>::, const std::tuple, std::in_place_type_t > > > >&>' /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/tuple:1730:14: requi= red from 'constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&) [with _Fn =3D cld::detail::CommandLine::parseOptions, {detail::INCLUDESbind0, std::in_place_type > >}>::; _Tuple =3D const std::tuple, std::in_place_type_t > > > >&]' :456:36: required from 'constexpr auto cld::detail::CommandLine::parseOptions(std::string_view, cld::CLIMultiArg) [with T =3D cld::detail::CommandLine::Pack; auto& ...args =3D {detail::INCLUDESbind0, std::in_place_type > >}; std::string_view =3D std::basic_string_view]' :502:62: required from here /opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/string_view:287:34: er= ror: 'char cld::Constexpr::basic_fixed_string::m_data [7]' is private within this context 287 | return basic_string_view{_M_str + __pos, __rlen}; | ~~~~~~~^~~~~~~ :18:5: note: declared private here 18 | T m_data[N] =3D {}; |=20 I tried to create a minimum reproducible from scratch but failed to so. Ins= tead I now used my code and tried to minimize that as much as possible which sad= ly still amounts to 500 lines of code but does reproduce the issue. I have attached the file. To my knowledge the code is correct and clang and MSVC compile it without issues. Changing m_data in basic_fixed_string from private to public makes = the build succeed. Every version of GCC 8 to trunk fail with the same error. GC= C 7 instead has an internal compiler error. Alternatively see this compiler explorer link: https://godbolt.org/z/snnfo7=