From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4E2733877010; Sat, 21 Mar 2020 23:50:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E2733877010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584834642; bh=ZQyT46NvWS0CH4uSd2npKQzm8ltdK9fRD/nFZb5Dt2Y=; h=From:To:Subject:Date:From; b=IsqmNDjcjLlT4JseYaQwdffOrXGK/nLAEtlCgnE3T5DeTgvihO0L8QGKikf5dhTlr ucj0g5D2uxjkCmg2a/FwDG/6M0bicHGUuo62fJ4wUQbWcLzO2RCu4WS4iKREbW4j77 oLew1YyBft2ut4RyJW5K1UlCiTRPliwzMX05Re94= From: "vince.a.bridgers at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94255] New: template specialization in different namespace causes crash Date: Sat, 21 Mar 2020 23:50:42 +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: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vince.a.bridgers 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: Sat, 21 Mar 2020 23:50:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94255 Bug ID: 94255 Summary: template specialization in different namespace causes crash Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vince.a.bridgers at gmail dot com Target Milestone: --- I encountered this issue using gcc/g++ 6.2.0, then 8.2.0, the tried trunk t= hat I built on rhel7. g++ crashes when trying to compile code with template specialization in different namespace. I know this is incorrect code, but I wouldn't expect g++ to crash. For reference, clang 8.0.0 compiles this and gives an error.=20 ---- Last git hash in log commit 9def91e9f2a7051c9c146f16c1a10d1b25d33b47 Author: Jakub Jelinek Date: Thu Mar 19 22:56:20 2020 +0100 --- Configure step for custom, trunk build ...=20 ../gcc/configure --enable-languages=3Dc,c++ --disable-multilib --prefix=3D/gcc-install ---- $ g++ --version g++ (GCC) 10.0.1 20200319 (experimental) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---- $ g++ gcc-test.cpp=20 gcc-test.cpp:15:38: error: specialization of =E2=80=98template struct clang::DynTypedNode::BaseConverter=E2=80=99 in different namespace [-fpermissive] 15 | template <> struct DynTypedNode::BaseConverter : pub= lic ValueConverter {}; | ^~~~~~~~~~~~~~~~~~~~~~~~ gcc-test.cpp:5:60: note: from definition of =E2=80=98template struct clang::DynTypedNode::BaseConverter=E2=80=99 5 | template struct BaseConverter; |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~ g++: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source if appropriate. See for instructions. ---- cat test.cpp ...=20 namespace clang { class DynTypedNode { private: template struct BaseConverter; template struct ValueConverter {}; }; namespace ast_type_traits { using DynTypedNode =3D ::clang::DynTypedNode; }; // end namespace ast_type_traits }; // end namespace clang namespace clang { namespace ast_type_traits { template <> struct DynTypedNode::BaseConverter : public ValueConverter {}; }; // end namespace ast_type_traits }; // end namespace clang int main(void) { return 0; } --- cat gcc-test.ii ... # 1 "gcc-test.cpp" # 1 "" # 1 "" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "" 2 # 1 "gcc-test.cpp" namespace clang { class DynTypedNode { private: template struct BaseConverter; template struct ValueConverter {}; }; namespace ast_type_traits { using DynTypedNode =3D ::clang::DynTypedNode; }; }; namespace clang { namespace ast_type_traits { template <> struct DynTypedNode::BaseConverter : public ValueConverter {}; }; }; int main(void) { return 0; } ---- $ clang --version clang version 8.0.0 (tags/RELEASE_800/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /app/vbuild/RHEL7-x86_64/clang/8.0.0/bin $ clang test.cpp=20 gcc-test.cpp:15:38: error: class template specialization of 'BaseConverter'= not in class 'DynTypedNode' or an enclosing namespace template <> struct DynTypedNode::BaseConverter : public ValueConverter {}; ^ gcc-test.cpp:5:60: note: explicitly specialized declaration is here template struct BaseConverter; ^ 1 error generated.=