Discussion:
[Bug c++/14186] New: const volatile is ignored for TYPE_INSTANCE
jan.kratochvil at redhat dot com
2012-05-30 22:21:58 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=14186

Bug #: 14186
Summary: const volatile is ignored for TYPE_INSTANCE
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: c++
AssignedTo: ***@sourceware.org
ReportedBy: ***@redhat.com
Classification: Unclassified


Trailing const or volatile get parsed by they are ignored.

Output $3 should match $2, not $1.

p 'CV::m(int)'
$1 = {void (CV * const, CV::t)} 0x400944 <CV::m(int)>

p 'CV::m(int) const'
$2 = {void (const CV * const, CV::t)} 0x400952 <CV::m(int) const>

p CV::m(int) const
$3 = {void (CV * const, CV::t)} 0x400944 <CV::m(int)>
KFAIL: gdb.cp/cpexprs.exp: p CV::m(int) const (PRMS: gdb/9999)

former c-exp.y line:
exp : exp '(' nonempty_typelist ')' const_or_volatile
or new line:
exp : exp '('
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
{ start_arglist (); }
arglist_final ')' const_or_volatile %prec ARROW
just ignore that 'const_or_volatile'.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
tromey at redhat dot com
2012-06-19 20:42:16 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=14186

Tom Tromey <tromey at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-06-19 20:42:16 UTC ---
I looked into this a bit. I have a partial patch.
It is turning out to be pretty ugly to pass the cv-qualifiers
from the parser down through OP_SCOPE to value_aggregate_elt.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
tromey at redhat dot com
2012-06-20 14:55:38 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=14186

--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2012-06-20 14:55:38 UTC ---
Created attachment 6461
--> http://sourceware.org/bugzilla/attachment.cgi?id=6461
start of a patch

Here's the start of a patch.

It has some unnecessary stuff in it, since I was hacking around
a bit. But some parts should be ok, like the c-exp.y change.

The TYPE_INSTANCE code seems very suspect to me. The parser production
just uses 'exp' -- but this means all kinds of weird things can be parsed
here. (On further reflection I wish I hadn't allowed this extension...)
Also the code in eval.c does not use cleanups, so it can leak memory on errors.

The fundamental problem I hit is that rank_one_type does not consider
cv-qualifiers. So, even after getting the qualifiers all the way through,
we still get the wrong answer; and I didn't want to try fixing this problem
yet.

The cv-qualifier problem could be hacked around in compare_parameters,
but that seemed too hackish for me.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
palves at redhat dot com
2017-09-20 18:31:51 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14186

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com

--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
Keith informed me today that I fixed this PR with this patch:

https://sourceware.org/ml/gdb-patches/2017-07/msg00147.html

commit 3693fdb3c8ec14bd8ecb4ebb39e4384b330a2999
Author: Pedro Alves <***@redhat.com>
AuthorDate: Mon Sep 4 20:21:16 2017 +0100

Make "p S::method() const::static_var" work too

Somehow I completely managed to overlook that that caused:

KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) volatile (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const volatile (PRMS c++/14186)

It pains me to realize that this had a partially written patch here...
There are some similarities, and some differences; In your version from 2012,
it seems like you avoided touching dwarf2read.c, with the "inexact_match"
check in value_struct_elt_for_reference, but I'm not really sure I understand
that. And now I'm wondering whether we're missing something in master around
overload resolution, since in the use case I was aiming for [accessing local
statics], I was only thinking of exact matches.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-17 16:18:51 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14186

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
I noticed today that these tests are still KPASS.
Maybe the kfail should be removed now.
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-04-17 17:09:40 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=14186

--- Comment #5 from Pedro Alves <palves at redhat dot com> ---
I agree.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...