public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/61321] New: demangler crash on casts in template parameters
@ 2014-05-26 14:03 palves at redhat dot com
  2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: palves at redhat dot com @ 2014-05-26 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61321
           Summary: demangler crash on casts in template parameters
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: palves at redhat dot com

The fix for bug 59195 (C++ demangler handles conversion operator incorrectly)
makes the demangler crash crash due to infinite recursion, in case of casts in
template parameters.  For example:

 template<int> struct A {};
 template <typename Y> void function_temp(A<sizeof ((Y)(999))>) {}
 template void function_temp<int>(A<sizeof (int)>);

The function_temp<int> instantiation  mangles to:
  _Z13function_tempIiEv1AIXszcvT_Li999EEE

The demangler parses this as:

typed name
  template
    name 'function_temp'
    template argument list
      builtin type int
  function type
    builtin type void
    argument list
      template
        name 'A'
        template argument list
          unary operator
            operator sizeof 
            unary operator
              cast
                template parameter 0
              literal
                builtin type int
                name '999'

And after this patch, when printing the template argument list of A (what
should be "<sizeof (int)>"), the template parameter 0 (that is, "T_") now
refers to the first parameter of the the template argument list of the 'A'
template, exactly what we were trying to print, while it should actually refer
to the first parameter of the 'function_temp' template.  This leads to infinite
recursion, and stack exaustion.

(This is particularly nasty for GDB, as it causes an immediate crash at
startup.)


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-08-18 23:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
2014-05-26 16:40 ` palves at redhat dot com
2014-05-26 20:52 ` redi at gcc dot gnu.org
2014-05-27 12:00 ` palves at redhat dot com
2014-11-10 19:01 ` ccoutant at gcc dot gnu.org
2014-11-10 19:19 ` ccoutant at gcc dot gnu.org
2015-07-06  4:56 ` trippels at gcc dot gnu.org
2015-07-06  5:14 ` trippels at gcc dot gnu.org
2015-07-14  9:39 ` palves at redhat dot com
2015-07-27 10:09 ` trippels at gcc dot gnu.org
2015-08-18 23:11 ` miyuki at gcc dot gnu.org

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).