Bug 5390 - [3.3 only?] Libiberty fails to demangle multi-digit template parameters.
Summary: [3.3 only?] Libiberty fails to demangle multi-digit template parameters.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 3.1
: P2 critical
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-15 10:16 UTC by carlo
Modified: 2003-07-18 03:22 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-06-14 21:44:38


Attachments
dem2.patch (1.71 KB, application/octet-stream)
2003-05-21 15:16 UTC, carlo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description carlo 2002-01-15 10:16:00 UTC
There is a bug in libiberty, cplus-dem.c
and the testsuite of libiberty regarding
multi-digit template parameters.

First PR that started this is at
http://sources.redhat.com/ml/bug-binutils/2002-q1/msg00021.html

I wrote a patch for this, for comments on the
patch please read:
http://sources.redhat.com/ml/bug-binutils/2002-q1/msg00023.html
The patch contained there is incomplete however.
I attached the full patch to this PR.

The PR was created because DJ Delorie told me patches
for libiberty need to go to gcc-patches@gcc.gnu.org
but I don't trust it to let a patch 'vanish' there :/

Release:
head revision of 'src' at 15 Jan 2002.

Environment:
i686-gnu-linux (not relevant though)
Comment 1 carlo 2002-01-15 10:16:00 UTC
Fix:
Apply attached patch.
Comment 2 carlo 2002-01-15 19:35:23 UTC
From: Carlo Wood <carlo@alinoe.com>
To: gcc-patches@gcc.gnu.org
Cc: dj@redhat.com, gcc-gnats@gcc.gnu.org
Subject: Re: other/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Tue, 15 Jan 2002 19:35:23 +0100

 --mYCpIKhGyMATD0i+
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 As promised, sending this patch also to gcc-patches@gcc.gnu.org
 
 The following patch fixes the problem that an integral template
 parameter larger than 9 or smaller than -9 was not demangled
 correctly (and even led to a core dump in libiberty).
 (This is only related to the old ABI, g++-2.95.x thus).
 
 Basically the change is as follows:
 
 Instead of reading integer numbers as
 
 	[m]<digit>
 
 or
 
 	_[m]<digit>[<digit>...]_
 
 It now simply reads
 
 	[m]<digit>[<digit>...]
 
 or
 
 	_[m]<digit>[<digit>...]_
 
 This is not a problem since g++-2.95.x never mangles
 names in a way that there would follow a digit that
 does not belong to the number.  However, the testsuite
 assumed that this was the case and was testing several
 incorrect mangled names.  I wrote little test cases
 to generate the symbols used in order to make sure that
 g++-2.95.3 indeed does generate mangled names as I
 thought it was. This patch also incorporates these
 changes (testsuite/demangle-expected).
 
 Obviously, after applying this test we get:
 ~/c/src/libiberty>make check
 make[1]: Entering directory `/home/carlo/c/src/libiberty/testsuite'
 /bin/sh ./regress-demangle ./demangle-expected
 All 646 tests passed
 make[1]: Leaving directory `/home/carlo/c/src/libiberty/testsuite'
 
 -- 
 Carlo Wood <carlo@alinoe.com>
 
 --mYCpIKhGyMATD0i+
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="dem2.patch"
 
 2002-01-10  Carlo Wood  <carlo@gnu.org>
 
 	* cplus-dem.c (demangle_integral_value): Accept multi-digit
 	numbers that do not start with an underscore; This is needed
 	for integer template parameters. This doesn't break anything
 	because multi-digit numbers are never followed by a digit.
 	* testsuite/demangle-expected: Corrected all mangled test
 	cases with multi-digit template parameters: g++ 2.95.x does
 	not generate underscores around these parameters.
 
 Index: cplus-dem.c
 ===================================================================
 RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
 retrieving revision 1.27
 diff -u -d -p -r1.27 cplus-dem.c
 --- cplus-dem.c	2002/01/03 00:25:57	1.27
 +++ cplus-dem.c	2002/01/15 17:45:04
 @@ -1787,40 +1787,54 @@ demangle_integral_value (work, mangled, 
  
        /* By default, we let the number decide whether we shall consume an
  	 underscore.  */
 -      int consume_following_underscore = 0;
 +      int multidigit_without_leading_underscore = 0;
        int leave_following_underscore = 0;
  
        success = 0;
  
 -      /* Negative numbers are indicated with a leading `m'.  */
 -      if (**mangled == 'm')
 -	{
 -	  string_appendn (s, "-", 1);
 -	  (*mangled)++;
 -	}
 -      else if (mangled[0][0] == '_' && mangled[0][1] == 'm')
 +      if (**mangled == '_')
  	{
 -	  /* Since consume_count_with_underscores does not handle the
 -	     `m'-prefix we must do it here, using consume_count and
 -	     adjusting underscores: we have to consume the underscore
 -	     matching the prepended one.  */
 -	  consume_following_underscore = 1;
 -	  string_appendn (s, "-", 1);
 -	  (*mangled) += 2;
 +	  if (mangled[0][1] == 'm')
 +	    {
 +	      /* Since consume_count_with_underscores does not handle the
 +		 `m'-prefix we must do it here, using consume_count and
 +		 adjusting underscores: we have to consume the underscore
 +		 matching the prepended one.  */
 +	      multidigit_without_leading_underscore = 1;
 +	      string_appendn (s, "-", 1);
 +	      (*mangled) += 2;
 +	    }
 +	  else
 +            {
 +	      /* Do not consume a following underscore;
 +	         consume_count_with_underscores will consume what
 +		 should be consumed.  */
 +	      leave_following_underscore = 1;
 +	    }
  	}
 -      else if (**mangled == '_')
 +      else
  	{
 -	  /* Do not consume a following underscore;
 -	     consume_following_underscore will consume what should be
 -	     consumed.  */
 +	  /* Negative numbers are indicated with a leading `m'.  */
 +	  if (**mangled == 'm')
 +	  {
 +	    string_appendn (s, "-", 1);
 +	    (*mangled)++;
 +	  }
 +	  /* Since consume_count_with_underscores does not handle
 +	     multi-digit numbers that do not start with an underscore,
 +	     and this number can be an integer template parameter,
 +	     we have to call consume_count. */
 +	  multidigit_without_leading_underscore = 1;
 +	  /* These multi-digit numbers never end on an underscore,
 +	     so if there is one then don't eat it. */
  	  leave_following_underscore = 1;
  	}
  
 -      /* We must call consume_count if we expect to remove a trailing
 -	 underscore, since consume_count_with_underscores expects
 -	 the leading underscore (that we consumed) if it is to handle
 +      /* We must call consume_count if we have no leading underscore,
 +	 since consume_count_with_underscores expects one (that we
 +	 consumed or wasn't there to begin with) if it is to handle
  	 multi-digit numbers.  */
 -      if (consume_following_underscore)
 +      if (multidigit_without_leading_underscore)
  	value = consume_count (mangled);
        else
  	value = consume_count_with_underscores (mangled);
 @@ -1838,7 +1852,7 @@ demangle_integral_value (work, mangled, 
  	     is wrong.  If other (arbitrary) cases are followed by an
  	     underscore, we need to do something more radical.  */
  
 -	  if ((value > 9 || consume_following_underscore)
 +	  if ((value > 9 || multidigit_without_leading_underscore)
  	      && ! leave_following_underscore
  	      && **mangled == '_')
  	    (*mangled)++;
 Index: testsuite/demangle-expected
 ===================================================================
 RCS file: /cvs/src/src/libiberty/testsuite/demangle-expected,v
 retrieving revision 1.6
 diff -u -d -p -r1.6 demangle-expected
 --- demangle-expected	2001/12/13 00:05:32	1.6
 +++ demangle-expected	2002/01/15 17:45:06
 @@ -2476,15 +2476,15 @@ fn__FPQ21n1cPMQ21n1cFPQ21n1c_i
  fn(n::c *, int (n::c::*)(n::c *))
  #
  --format=gnu
 -f__FGt3Bar1i21i
 +f__FGt3Bar1i2G1i
  f(Bar<2>, i)
  #
  --format=gnu
 -f__FGt3Bar1i_21_i
 +f__FGt3Bar1i21i
  f(Bar<21>, int)
  #
  --format=gnu
 -f__FGt3Bar1i24XY_t
 +f__FGt3Bar1i2G4XY_t
  f(Bar<2>, XY_t)
  #
  --format=gnu
 @@ -2492,11 +2492,11 @@ foo__H1Zt2TA2ZRCiZt2NA1Ui9_X01_i
  int foo<TA<int const &, NA<9> > >(TA<int const &, NA<9> >)
  #
  --format=gnu
 -foo__H1Zt2TA2ZcZt2NA1Ui_20__X01_i
 +foo__H1Zt2TA2ZcZt2NA1Ui20_X01_i
  int foo<TA<char, NA<20> > >(TA<char, NA<20> >)
  #
  --format=gnu
 -foo__H1Zt2TA2ZiZt8N___A___1Ui_99__X01_i
 +foo__H1Zt2TA2ZiZt8N___A___1Ui99_X01_i
  int foo<TA<int, N___A___<99> > >(TA<int, N___A___<99> >)
  #
  --format=gnu
 @@ -2508,7 +2508,7 @@ foo__H1Zt2TA2ZRCiZt2NA1im9_X01_i
  int foo<TA<int const &, NA<-9> > >(TA<int const &, NA<-9> >)
  #
  --format=gnu
 -foo__H1Zt2TA2ZcZt2NA1i_m20__X01_i
 +foo__H1Zt2TA2ZcZt2NA1im20_X01_i
  int foo<TA<char, NA<-20> > >(TA<char, NA<-20> >)
  #
  --format=gnu
 @@ -2520,7 +2520,7 @@ foo__H1Zt2TA2ZiZt4N__A1im9_X01_i
  int foo<TA<int, N__A<-9> > >(TA<int, N__A<-9> >)
  #
  --format=gnu
 -foo__H1Zt2TA2ZiZt4N__A1i_m99__X01_i
 +foo__H1Zt2TA2ZiZt4N__A1im99_X01_i
  int foo<TA<int, N__A<-99> > >(TA<int, N__A<-99> >)
  #
  --format=gnu
 @@ -2528,15 +2528,15 @@ __opi__t2TA2ZiZt4N__A1i9
  TA<int, N__A<9> >::operator int(void)
  #
  --format=gnu
 -__opi__t2TA2ZiZt8N___A___1i_m99_
 +__opi__t2TA2ZiZt8N___A___1im99
  TA<int, N___A___<-99> >::operator int(void)
  #
  --format=gnu
 -foo___bar__baz_____H1Zt2TA2ZiZt8N___A___1i_99__X01_i
 +foo___bar__baz_____H1Zt2TA2ZiZt8N___A___1i99_X01_i
  int foo___bar__baz___<TA<int, N___A___<99> > >(TA<int, N___A___<99> >)
  #
  --format=gnu
 -foo__bar___foobar_____t2TA2ZiZt8N___A___1i_m99_
 +foo__bar___foobar_____t2TA2ZiZt8N___A___1im99
  TA<int, N___A___<-99> >::foo__bar___foobar___(void)
  #
  --format=gnu
 
 --mYCpIKhGyMATD0i+--

Comment 3 Hans-Peter Nilsson 2002-01-15 22:59:00 UTC
From: Hans-Peter Nilsson <hp@bitrange.com>
To: Carlo Wood <carlo@alinoe.com>
Cc: <gcc-patches@gcc.gnu.org>,  <dj@redhat.com>,  <gcc-gnats@gcc.gnu.org>
Subject: Re: other/5390: Libiberty fails to demangle multi-digit template
 parameters.
Date: Tue, 15 Jan 2002 22:59:00 -0500 (EST)

 On Tue, 15 Jan 2002, Carlo Wood wrote:
 
 > As promised, sending this patch also to gcc-patches@gcc.gnu.org
 >
 > The following patch fixes the problem that an integral template
 > parameter larger than 9 or smaller than -9 was not demangled
 > correctly (and even led to a core dump in libiberty).
 > (This is only related to the old ABI, g++-2.95.x thus).
 
 >
 > This is not a problem since g++-2.95.x never mangles
 > names in a way that there would follow a digit that
 > does not belong to the number.  However, the testsuite
 > assumed that this was the case and was testing several
 > incorrect mangled names.
 
 IIRC, this is because of blessed backward-compatibility.  Names
 mangled with earlier GCC releases (earlier than gcc-2.95) are
 supposed to be demanglable (when at all possible).  If you have
 checked this, please say so.  Maybe it's not important any
 longer.
 
 brgds, H-P
 

Comment 4 carlo 2002-01-16 05:16:21 UTC
From: Carlo Wood <carlo@alinoe.com>
To: Hans-Peter Nilsson <hp@bitrange.com>
Cc: gcc-patches@gcc.gnu.org, dj@redhat.com, gcc-gnats@gcc.gnu.org
Subject: Re: other/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Wed, 16 Jan 2002 05:16:21 +0100

 On Tue, Jan 15, 2002 at 10:59:00PM -0500, Hans-Peter Nilsson wrote:
 > IIRC, this is because of blessed backward-compatibility.  Names
 > mangled with earlier GCC releases (earlier than gcc-2.95) are
 > supposed to be demanglable (when at all possible).  If you have
 > checked this, please say so.  Maybe it's not important any
 > longer.
 
 I didn't check compilers older than 2.95.  But even if this patch
 would break demangling for those older compilers, then it seems
 more important to me to have 2.95 working and older broken then
 vica versa.  It is not possible to support both.
 
 That last remark is based on the following logic: When decoding
 integers as <digit>[<digit>...] would break something, then
 apparently the older compilers will generate mangled names
 like: "__FGt3Bar1i21i" demanding that you treat the "i2" as
 a single digit integer (resulting: f(Bar<2>, i)).
 But g++-2.95 will generate "__FGt3Bar1i21i" for f(Bar<21>, int)
 and hence it is impossible to support both.  I'd say:
 demangle "__FGt3Bar1i21i" as f(Bar<21>, int) ...
 
 -- 
 Carlo Wood <carlo@alinoe.com>
Comment 5 Wolfgang Bangerth 2003-03-07 02:26:50 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: Carlo, this report has been sitting idly for a year now.
    What is the present state? Is it still unsolved, or did
    your patch go in?
    
    Thanks
      Wolfgang
Comment 6 Wolfgang Bangerth 2003-03-07 10:03:32 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Carlo Wood <carlo@alinoe.com>
Cc: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template
 parameters.
Date: Fri, 7 Mar 2003 10:03:32 -0600 (CST)

 Carlo,
 first this: When I complained that this PR has been sitting idle despite 
 the fact that it has a patch, I complained to the ones who are in power of 
 reviewing and applying patches. That it has not been reviewed is not your 
 fault. We are grateful for people sending in patches, and I, too, am 
 embarrassed if we turn them down by just not taking notice of their 
 work...
 
 > > State-Changed-From-To: open->feedback
 > > State-Changed-Why:
 > >     Carlo, this report has been sitting idly for a year now.
 > >     What is the present state? Is it still unsolved, or did
 > >     your patch go in?
 > [...]
 > 
 > c++filt of 3.3 does not demangle the correct mangled names (at least the
 > ones I tried) - while it does demangle the old (wrong) mangled names. 
 
 As time progresses, this is becoming more and more irrelevant: as far 
 as I understand you,
 - gcc since 3.0 has a different mangling scheme, which isn't concerned in 
   this PR 
 - gcc up to 2.95 has never generated the cases that your patch addresses
 - gcc 2.95 is certainly not going to be fixed to generate them any more
 - gcc 2.95 is slowly dying out.
 
 The question thus is: if people are not overly interested in your patch 
 (which is regrettable, but apparently the case), then we can as well close 
 the PR. Since if we don't, we'll ask the same question again in a year, 
 and then people will care even less about 2.95.
 
 What's your opinion on this?
 
 Thanks
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 

Comment 7 DJ Delorie 2003-03-07 12:18:18 UTC
From: DJ Delorie <dj@redhat.com>
To: carlo@alinoe.com
Cc: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
   nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Fri, 7 Mar 2003 12:18:18 -0500

 Vlad reported a core dump.  Nick fixed it with a small patch.  You
 also wrote a significantly larger patch also claiming to fix it.  You
 were asked if you tested on older gcc's to ensure backward
 compatibility.  You said you didn't.  The issue of backward
 compatibility was never resolved to my satisfaction, so I didn't
 approve it.  I also noted that the demanglers are normally maintained
 by the C++ folks, but apparently you didn't convince them either.
 
 However, if you look in libiberty's ChangeLog, you'll see that your
 patch was eventually applied, over a year ago.  So, I'm not sure what
 you're complaining about.
 
 2002-02-18  Carlo Wood  <carlo@gnu.org>
 
 	PR c++/5390
 	* cplus-dem.c (demangle_integral_value): Accept multi-digit
 	numbers that do not start with an underscore; This is needed
 	for integer template parameters. This doesn't break anything
 	because multi-digit numbers are never followed by a digit.
 	* testsuite/demangle-expected: Corrected all mangled test
 	cases with multi-digit template parameters: g++ 2.95.x does
 	not generate underscores around these parameters.

Comment 8 carlo 2003-03-07 13:14:20 UTC
From: Carlo Wood <carlo@alinoe.com>
To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
  nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Fri, 7 Mar 2003 13:14:20 +0100

 On Fri, Mar 07, 2003 at 02:26:50AM -0000, bangerth@dealii.org wrote:
 > Synopsis: Libiberty fails to demangle multi-digit template parameters.
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: bangerth
 > State-Changed-When: Fri Mar  7 02:26:50 2003
 > State-Changed-Why:
 >     Carlo, this report has been sitting idly for a year now.
 >     What is the present state? Is it still unsolved, or did
 >     your patch go in?
 >     
 >     Thanks
 >       Wolfgang
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5390
 
 
 I don't have 2.95.4 and don't even know if there is a CVS branch for it.
 
 The file libiberty/testsuite/demangle-expected still exists in version 3.3,
 and contains some broken mangled names (the way 2.95.x doesn't mangle them):
 my patch was not applied to 'libiberty/testsuite/demangle-expected' but it
 seems to have been partly applied, or someone did double work (and a bad job).
 
 c++filt of 3.3 does not demangle the correct mangled names (at least the
 ones I tried) - while it does demangle the old (wrong) mangled names.  By
 looking at libiberty/cplus-dem.c it seems that the patch was at least party
 applied, but someone made changes that broke it, or they ignored failing
 hunks.  As it is, libiberty/cplus-dem.c cannot demangle all the names as
 produced by 2.95.x.
 
 Because in the past my patches have been totally ignored too often, I did put
 this one in the bugs database, so it wouldn't get lost... But later I got so
 much demotivated that I unsubbed from all gcc mailinglists and stopped
 caring about gcc.  Therefore I must say now: I am sorry, but I can't bother
 to put more time into this one and fix it AGAIN - for the current cplus-dem.c.
 Perhaps you manage to manually fix the current cplus-dem.c by looking at
 the old patch and figuring out what was applied and what was not applied.
 Keep in mind that it is not possible, nor interesting to keep backwards
 compatibility with the mangled names as mangled by pre-2.95.x (the ones
 with a '-' in front of it in my testsuite/demangle-expected patch) in
 libiberty/testsuite/demangle-expected: if you do that then you garanteed
 have a broken demangler for the way 2.95.x mangles these names.  My patch
 (for cplus-dem.c) was the best possible fix imho.
 
 -- 
 Carlo Wood <carlo@alinoe.com>

Comment 9 carlo 2003-03-08 00:14:43 UTC
From: Carlo Wood <carlo@alinoe.com>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Sat, 8 Mar 2003 00:14:43 +0100

 On Fri, Mar 07, 2003 at 10:03:32AM -0600, Wolfgang Bangerth wrote:
 > As time progresses, this is becoming more and more irrelevant: as far 
 > as I understand you,
 > - gcc since 3.0 has a different mangling scheme, which isn't concerned in 
 >   this PR 
 > - gcc up to 2.95 has never generated the cases that your patch addresses
 
 It does.  That is the whole point: 2.95 generates mangled names that are
 not supported, while the mangled names produces by older version ARE
 supported.
 
 > - gcc 2.95 is certainly not going to be fixed to generate them any more
 > - gcc 2.95 is slowly dying out.
 > 
 > The question thus is: if people are not overly interested in your patch 
 > (which is regrettable, but apparently the case), then we can as well close 
 > the PR. Since if we don't, we'll ask the same question again in a year, 
 > and then people will care even less about 2.95.
 > 
 > What's your opinion on this?
 
 The reason I filed the PR was because my library generated a mangled
 name that made libiberty core.  As a library developer I *have* to
 support ALL versions of gcc(/libiberty) and was able to think of
 a workaround (somehow make sure that the template parameter constant
 where always < 10).  It is never urgent for to have something fixed:
 I have to work with the current version (2.95.1 and up, all of them)
 anyway.  So, as far as I am concerned you can close this PR.
 (Personally, I'd fix it though if I were you - but I am a perfectionist).
 
 -- 
 Carlo Wood <carlo@alinoe.com>

Comment 10 Wolfgang Bangerth 2003-03-10 15:03:05 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Carlo Wood <carlo@alinoe.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template
 parameters.
Date: Mon, 10 Mar 2003 15:03:05 -0600 (CST)

 > > - gcc up to 2.95 has never generated the cases that your patch addresses
 > 
 > It does.  That is the whole point: 2.95 generates mangled names that are
 > not supported, while the mangled names produces by older version ARE
 > supported.
 
 OK, thanks for the clarifications. I wasn't aware of this ABI change back 
 then.
 
 
 > > The question thus is: if people are not overly interested in your patch 
 > > (which is regrettable, but apparently the case), then we can as well close 
 > > the PR. Since if we don't, we'll ask the same question again in a year, 
 > > and then people will care even less about 2.95.
 > > 
 > > What's your opinion on this?
 > 
 > The reason I filed the PR was because my library generated a mangled
 > name that made libiberty core.  As a library developer I *have* to
 > support ALL versions of gcc(/libiberty) and was able to think of
 > a workaround (somehow make sure that the template parameter constant
 > where always < 10).  It is never urgent for to have something fixed:
 > I have to work with the current version (2.95.1 and up, all of them)
 > anyway.
 
 I understand these concerns. We build our library by 3 or 4 different 
 compilers and a total of 10 different versions or so :-(
 
 >  So, as far as I am concerned you can close this PR.
 
 Does this still hold given DJ's mail?
 
 
 > (Personally, I'd fix it though if I were you - but I am a perfectionist).
 
 I might if I could. I have no knowledge of gcc, libiberty, etc at all. My 
 place is gnats, beyond that I can only try to get patch creators and 
 reviewers into contact -- usually a fruitless endeavor...
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 
 

Comment 11 carlo 2003-03-11 03:23:41 UTC
From: Carlo Wood <carlo@alinoe.com>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org, dj@redhat.com
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Tue, 11 Mar 2003 03:23:41 +0100

 --zhXaljGHf11kAtnf
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Mon, Mar 10, 2003 at 03:03:05PM -0600, Wolfgang Bangerth wrote:
 > >  So, as far as I am concerned you can close this PR.
 > 
 > Does this still hold given DJ's mail?
 > 
 > > (Personally, I'd fix it though if I were you - but I am a perfectionist).
 > 
 > I might if I could. I have no knowledge of gcc, libiberty, etc at all. My 
 > place is gnats, beyond that I can only try to get patch creators and 
 > reviewers into contact -- usually a fruitless endeavor...
 
 I tested it again and, as I've written to DJ in private, it seems
 that my patch WAS applied more or less to gcc version 3.1.
 However, the way it is now is that it doesn't work for negative
 template integrals less than -9.
 
 For example:
 
 /usr/src/gcc/gcc-cvs-3.3/libiberty>echo 'main(int argc, char* argv[]) { printf("%s\n", cplus_demangle(argv[1], 3)); }' > main.c
 /usr/src/gcc/gcc-cvs-3.3/libiberty>gcc -I../include cplus-dem.c safe-ctype.c xmalloc.c xexit.c xstrdup.c cp-demangle.c dyn-string.c main.c
 /usr/src/gcc/gcc-cvs-3.3/libiberty>a.out X__FGt3Bar1im10i
 X(Bar<-1>, , int)
 
 I corrected cplus-dem.c again to completely reflect my original patch
 after which I get correctly:
 
 /usr/src/gcc/gcc-cvs-3.3/libiberty>a.out X__FGt3Bar1im10i
 X(Bar<-10>, int)
 
 
 The new diff is attached.
 
 Log entry:
 
 
 2003-03-10  Carlo Wood  <carlo@gnu.org>
 
         * cplus-dem.c (demangle_integral_value): Correction to reflect
 	patch of 2002-01-10 in order to also make negative multi-digits
 	without leading underscore work.
 
 -- 
 Carlo Wood <carlo@alinoe.com>
 
 --zhXaljGHf11kAtnf
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="dem3.diff"
 
 Index: cplus-dem.c
 ===================================================================
 RCS file: /cvsroot/gcc/gcc/libiberty/cplus-dem.c,v
 retrieving revision 1.89.4.1
 diff -u -d -p -r1.89.4.1 cplus-dem.c
 --- cplus-dem.c	4 Mar 2003 02:57:48 -0000	1.89.4.1
 +++ cplus-dem.c	11 Mar 2003 02:07:23 -0000
 @@ -1797,31 +1797,34 @@ demangle_integral_value (work, mangled, 
  
        success = 0;
  
 -      /* Negative numbers are indicated with a leading `m'.  */
 -      if (**mangled == 'm')
 -	{
 -	  string_appendn (s, "-", 1);
 -	  (*mangled)++;
 -	}
 -      else if (mangled[0][0] == '_' && mangled[0][1] == 'm')
 -	{
 -	  /* Since consume_count_with_underscores does not handle the
 -	     `m'-prefix we must do it here, using consume_count and
 -	     adjusting underscores: we have to consume the underscore
 -	     matching the prepended one.  */
 -	  multidigit_without_leading_underscore = 1;
 -	  string_appendn (s, "-", 1);
 -	  (*mangled) += 2;
 -	}
 -      else if (**mangled == '_')
 -	{
 -	  /* Do not consume a following underscore;
 -	     multidigit_without_leading_underscore will consume what should be
 -	     consumed.  */
 -	  leave_following_underscore = 1;
 +      if (**mangled == '_')
 +        {
 +	  if (mangled[0][1] == 'm')
 +	    {
 +	      /* Since consume_count_with_underscores does not handle the
 +		 `m'-prefix we must do it here, using consume_count and
 +		 adjusting underscores: we have to consume the underscore
 +		 matching the prepended one.  */
 +	      multidigit_without_leading_underscore = 1;
 +	      string_appendn (s, "-", 1);
 +	      (*mangled) += 2;
 +	    }
 +	  else
 +	    {
 +	      /* Do not consume a following underscore;
 +	         consume_count_with_underscores will consume what
 +	         should be consumed.  */
 +	      leave_following_underscore = 1;
 +	    }
  	}
        else
  	{
 +	  /* Negative numbers are indicated with a leading `m'.  */
 +	  if (**mangled == 'm')
 +	  {
 +	    string_appendn (s, "-", 1);
 +	    (*mangled)++;
 +	  }
  	  /* Since consume_count_with_underscores does not handle
  	     multi-digit numbers that do not start with an underscore,
  	     and this number can be an integer template parameter,
 @@ -1862,7 +1865,7 @@ demangle_integral_value (work, mangled, 
  	  /* All is well.  */
  	  success = 1;
  	}
 -    }
 +      }
  
    return success;
  }
 
 --zhXaljGHf11kAtnf--

Comment 12 Wolfgang Bangerth 2003-03-11 14:03:55 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: DJ Delorie <dj@redhat.com>
Cc: carlo@alinoe.com, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template
 parameters.
Date: Tue, 11 Mar 2003 14:03:55 -0600 (CST)

 Carlo, DJ,
 many thanks for working this out in a professional manner!
 
 I assume I can close the report now, right?
 
 Thanks
   Wolfgang
 
 
 On Tue, 11 Mar 2003, DJ Delorie wrote:
 
 > 
 > > 2003-03-10  Carlo Wood  <carlo@gnu.org>
 > > 
 > >         * cplus-dem.c (demangle_integral_value): Correction to reflect
 > > 	patch of 2002-01-10 in order to also make negative multi-digits
 > > 	without leading underscore work.
 > 
 > Approved and applied.  Thanks!
 > 
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 

Comment 13 DJ Delorie 2003-03-11 14:55:47 UTC
From: DJ Delorie <dj@redhat.com>
To: carlo@alinoe.com
Cc: bangerth@ticam.utexas.edu, gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters.
Date: Tue, 11 Mar 2003 14:55:47 -0500

 > 2003-03-10  Carlo Wood  <carlo@gnu.org>
 > 
 >         * cplus-dem.c (demangle_integral_value): Correction to reflect
 > 	patch of 2002-01-10 in order to also make negative multi-digits
 > 	without leading underscore work.
 
 Approved and applied.  Thanks!

Comment 14 Mark Mitchell 2003-05-02 11:18:25 UTC
From: Mark Mitchell <mark@codesourcery.com>
To: Wolfgang Bangerth <bangerth@ices.utexas.edu>
Cc: DJ Delorie <dj@redhat.com>, carlo@alinoe.com, gcc-gnats@gcc.gnu.org,  gcc-patches@gcc.gnu.org
Subject: Re: other/5390: What about this PR?
Date: 02 May 2003 11:18:25 -0700

 On Fri, 2003-05-02 at 11:13, Wolfgang Bangerth wrote:
 > On Fri, 2 May 2003, DJ Delorie wrote:
 > 
 > > 
 > > > I think it might as well be applied to the 3.3 branch,
 > > > but if not - then this PR can be closed: its status
 > > > still sits at 'feedback'.
 > > 
 > > At this point, it's not up to me.  If the 3.3 branch folks want to
 > > apply the patch, it's OK with me.
 > 
 > So this is Mark's call.
 > 
 > If it's not going into 3.3, please queue it for 3.3.1.
 
 Too late for 3.3, but OK for 3.3.1.
 
 Thanks,
 
 -- 
 Mark Mitchell <mark@codesourcery.com>
 CodeSourcery, LLC
Comment 15 Wolfgang Bangerth 2003-05-02 13:13:57 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: DJ Delorie <dj@redhat.com>
Cc: carlo@alinoe.com, <gcc-gnats@gcc.gnu.org>, <gcc-patches@gcc.gnu.org>,
   <mark@codesourcery.com>
Subject: Re: other/5390: What about this PR?
Date: Fri, 2 May 2003 13:13:57 -0500 (CDT)

 On Fri, 2 May 2003, DJ Delorie wrote:
 
 > 
 > > I think it might as well be applied to the 3.3 branch,
 > > but if not - then this PR can be closed: its status
 > > still sits at 'feedback'.
 > 
 > At this point, it's not up to me.  If the 3.3 branch folks want to
 > apply the patch, it's OK with me.
 
 So this is Mark's call.
 
 If it's not going into 3.3, please queue it for 3.3.1.
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
 
 

Comment 16 DJ Delorie 2003-05-02 13:16:07 UTC
From: DJ Delorie <dj@redhat.com>
To: carlo@alinoe.com
Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org, bangerth@ices.utexas.edu
Subject: Re: other/5390: What about this PR?
Date: Fri, 2 May 2003 13:16:07 -0400

 > I think it might as well be applied to the 3.3 branch,
 > but if not - then this PR can be closed: its status
 > still sits at 'feedback'.
 
 At this point, it's not up to me.  If the 3.3 branch folks want to
 apply the patch, it's OK with me.

Comment 17 carlo 2003-05-02 14:53:05 UTC
From: Carlo Wood <carlo@alinoe.com>
To: gcc-gnats@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org, bangerth@ticam.utexas.edu, dj@redhat.com
Subject: other/5390: What about this PR?
Date: Fri, 2 May 2003 14:53:05 +0200

 Just now I did a 'cvs diff' on the gcc-3.3 branch
 and found a modified file: cplus-dem.c
 
 This diff turned out to be related to PR other/5390
 
 It turns out that my patch (made for 3.3 at the time)
 was applied to 3.4 only.
 
 I think it might as well be applied to the 3.3 branch,
 but if not - then this PR can be closed: its status
 still sits at 'feedback'.
 
 -- 
 Carlo Wood <carlo@alinoe.com>

Comment 18 Dara Hazeghi 2003-06-02 02:12:24 UTC
DJ,

do you think that the patch for this PR that was applied to mainline can now be applied to 3.3 
branch? Thanks,

Dara
Comment 19 Andrew Pinski 2003-06-14 21:44:38 UTC
This should not be in waiting.
Comment 20 Mark Mitchell 2003-07-18 03:22:27 UTC
This has been fixed on the mainline.  I don't think it's worth trying to sort
this out for the 3.3 branch, so I have closed the PR.