From: Elena Zannoni <ezannoni@cygnus.com>
To: Jim Blandy <jimb@cygnus.com>
Cc: Elena Zannoni <ezannoni@cygnus.com>,
Daniel Berlin <dan@cgsoftware.com>,
gdb-patches@sources.redhat.com
Subject: Re: [RFA] linespec.c change to stop "malformed template specification" error
Date: Thu, 07 Jun 2001 07:40:00 -0000 [thread overview]
Message-ID: <15135.37463.301545.370875@kwikemart.cygnus.com> (raw)
In-Reply-To: <npg0dd2b20.fsf@zwingli.cygnus.com>
Jim Blandy writes:
>
> Elena Zannoni <ezannoni@cygnus.com> writes:
> > Daniel Berlin writes:
> > > This error is cause by find_toplevel_char not knowing that '<' and '>'
> > > increase and decrease the depth we are at.
> > >
> > > The result is that if you say "break _Rb_tree<int, int>", when it goes
> > > to look for a comma at the top level, it thinks it found one right
> > > after the "int", and temporarily truncates the string to '_Rb_tree<int,'
> > > When we then proceed to go through the string, we see the "<", and
> > > then go to find the end of the template name, and can't, because we've
> > > truncated the string in the wrong place, and issue an error.
> > >
> > > Cute, no?
> > >
> > > --Dan
> > >
> >
> > Seems OK to me, but could you update the comment on top of the
> > find_toplevel_char() to reflect that the char is looked for also
> > outside of '<' and '>' pairs?
> >
> > Any of the other maintainers (Jim, Fernando) has any comments?
>
> Operators like '<' can appear in template arguments. For example, you
> could define a template like this:
>
> template <int i> struct list { int a[i], b[i]; };
>
> and then use it like this:
>
> struct list <20> l;
>
> and you get the same thing as if you'd written:
>
> struct { int a[20], b[20]; } l;
>
> At least I think so, anyway. I don't really know C++. But the point
> is, those template arguments can be any arbitrary constant expression.
> So I could have a template invocation like this:
>
> struct list < (x < y) ? 10 : 20 > l;
>
> So how does our poor little decode_line_1 handle that? Basically, we
> need to replace decode_line_1 with a real parser.
I am not sure that decode_line_1 will ever be invoked in such a case.
Looking at when it's called, it seems to be only when you specify
a location, not an expression, and that occurs for 'break blah' and
'list blah' only. Also, find_toplevel_char is called only when looking
for a comma, so even with your example it should still work fine,
even though the 'depth' variable will have an inaccurate value.
But yes, I agree, decode_line_1 is a mess.
Elena
>
> In the mean time, however, I think it's more important to recognize
> the template argument brackets at all than to handle template
> arguments that contain < and > operators.
>
> So with this caveat, I think the change is fine.
>
next prev parent reply other threads:[~2001-06-07 7:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-22 14:06 Daniel Berlin
2001-06-06 16:09 ` Elena Zannoni
2001-06-06 17:00 ` Fernando Nasser
2001-06-06 21:00 ` Jim Blandy
2001-06-06 22:09 ` Daniel Berlin
2001-06-07 8:40 ` Jim Blandy
2001-06-07 8:47 ` macro-expanding expressions in GDB Jim Blandy
2001-06-07 9:01 ` Daniel Berlin
2001-06-07 11:52 ` Jim Blandy
2001-06-07 12:04 ` Daniel Berlin
2001-06-07 11:16 ` Stan Shebs
2001-06-06 23:36 ` [RFA] linespec.c change to stop "malformed template specification" error Daniel Berlin
2001-06-07 6:00 ` Fernando Nasser
2001-06-07 9:09 ` Jim Blandy
2001-06-07 7:40 ` Elena Zannoni [this message]
[not found] ` <nppucg1eq5.fsf@zwingli.cygnus.com>
2001-06-07 9:13 ` Daniel Berlin
2001-06-07 11:18 ` Jim Blandy
2001-06-07 11:35 ` Daniel Berlin
2001-06-07 15:22 ` Jim Blandy
2001-06-07 16:40 ` Daniel Berlin
2001-06-07 10:27 ` Elena Zannoni
2001-06-07 12:30 ` Fernando Nasser
2001-06-07 15:14 ` Jim Blandy
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=15135.37463.301545.370875@kwikemart.cygnus.com \
--to=ezannoni@cygnus.com \
--cc=dan@cgsoftware.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@cygnus.com \
/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: link
Be 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