This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64574] New: ICE (stack overflow SEGV) with bad template specialization


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64574

            Bug ID: 64574
           Summary: ICE (stack overflow SEGV) with bad template
                    specialization
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b.r.longbons at gmail dot com

Created attachment 34429
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34429&action=edit
reduced testcase

The attached C++ code is illegal because TraitCheckImpl<Swappable<T>> requires
TraitCheckImpl<Swappable<T>> to be complete already for Swappable<T>'s
defaulted second argument.

But it's still a compiler bug because it causes a stack overflow (-> segv ->
ICE) in cc1plus.

Bad versions:
g++-4.4.real (Debian 4.4.7-8) 4.4.7
g++-4.6.real (Debian 4.6.4-7) 4.6.4
g++-4.7.real (Debian 4.7.4-3) 4.7.4
g++-4.8.real (Debian 4.8.3-13) 4.8.3
g++-4.9.real (Debian 4.9.1-19) 4.9.1

Clang successfully errors out with a message about exceeding maximum template
instantiation depth (which is not the error I would've expected - something
about incomplete types).

The repeating portion of the backtrace (in gcc 4.9):

#11 0x000000000060bafe in complete_type(tree_node*) ()
#12 0x00000000005a3a02 in tsubst(tree_node*, tree_node*, int, tree_node*) ()
#13 0x00000000005a8673 in ?? ()
#14 0x00000000005a8b98 in ?? ()
#15 0x00000000005a3447 in tsubst(tree_node*, tree_node*, int, tree_node*) ()
#16 0x00000000005a8673 in ?? ()
#17 0x00000000005a31ec in tsubst(tree_node*, tree_node*, int, tree_node*) ()
#18 0x00000000005afa2f in ?? ()
#19 0x00000000005afd24 in ?? ()
#20 0x00000000005b4891 in instantiate_class_template(tree_node*) ()


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]