public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vince.a.bridgers at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-94255-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 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 that 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. ---- Last git hash in log commit 9def91e9f2a7051c9c146f16c1a10d1b25d33b47 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Mar 19 22:56:20 2020 +0100 --- Configure step for custom, trunk build ... ../gcc/configure --enable-languages=c,c++ --disable-multilib --prefix=<home>/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 gcc-test.cpp:15:38: error: specialization of ‘template<class T, class EnablerT> struct clang::DynTypedNode::BaseConverter’ in different namespace [-fpermissive] 15 | template <> struct DynTypedNode::BaseConverter<int, void> : public ValueConverter<int> {}; | ^~~~~~~~~~~~~~~~~~~~~~~~ gcc-test.cpp:5:60: note: from definition of ‘template<class T, class EnablerT> struct clang::DynTypedNode::BaseConverter’ 5 | template <typename T, typename EnablerT = void> struct BaseConverter; | ^~~~~~~~~~~~~ g++: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. ---- cat test.cpp ... namespace clang { class DynTypedNode { private: template <typename T, typename EnablerT = void> struct BaseConverter; template <typename T> struct ValueConverter {}; }; namespace ast_type_traits { using DynTypedNode = ::clang::DynTypedNode; }; // end namespace ast_type_traits }; // end namespace clang namespace clang { namespace ast_type_traits { template <> struct DynTypedNode::BaseConverter<int, void> : public ValueConverter<int> {}; }; // end namespace ast_type_traits }; // end namespace clang int main(void) { return 0; } --- cat gcc-test.ii ... # 1 "gcc-test.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "<command-line>" 2 # 1 "gcc-test.cpp" namespace clang { class DynTypedNode { private: template <typename T, typename EnablerT = void> struct BaseConverter; template <typename T> struct ValueConverter {}; }; namespace ast_type_traits { using DynTypedNode = ::clang::DynTypedNode; }; }; namespace clang { namespace ast_type_traits { template <> struct DynTypedNode::BaseConverter<int, void> : public ValueConverter<int> {}; }; }; 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 gcc-test.cpp:15:38: error: class template specialization of 'BaseConverter' not in class 'DynTypedNode' or an enclosing namespace template <> struct DynTypedNode::BaseConverter<int, void> : public ValueConverter<int> {}; ^ gcc-test.cpp:5:60: note: explicitly specialized declaration is here template <typename T, typename EnablerT = void> struct BaseConverter; ^ 1 error generated.
next reply other threads:[~2020-03-21 23:50 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-21 23:50 vince.a.bridgers at gmail dot com [this message] 2020-03-22 0:10 ` [Bug c++/94255] " vince.a.bridgers at gmail dot com 2020-03-22 4:15 ` xerofoify at gmail dot com 2020-03-22 4:15 ` xerofoify at gmail dot com 2020-03-27 19:47 ` mpolacek at gcc dot gnu.org 2020-04-18 3:48 ` mpolacek at gcc dot gnu.org 2020-04-20 19:26 ` mpolacek at gcc dot gnu.org 2020-05-07 18:12 ` cvs-commit at gcc dot gnu.org 2020-05-07 18:12 ` mpolacek at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94255-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).