Discussion:
[Bug c++/18881] New: bogus 'Cannot resolve function foo to any overloaded instance'
msebor at redhat dot com
2015-08-28 18:02:28 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18881

Bug ID: 18881
Summary: bogus 'Cannot resolve function foo to any overloaded
instance'
Product: gdb
Version: 7.8
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: msebor at redhat dot com
Target Milestone: ---

In the test case below, GNU gdb (GDB) Fedora 7.8.2-38.fc21 fails to resolve the
call to foo() in the ternary ?: expression even though it resolves it
successfully on its own. This makes debugging GCC difficult because it
prevents gdb from printing the values of some of the tree-checking macros. For
example:

(gdb) macro expand DECL_IS_BUILTIN((tree)expr)
expands to: (((IS_ADHOC_LOC (((contains_struct_check (((tree)expr),
(TS_DECL_MINIMAL), "/home/msebor/scm/fsf/gcc-66516/gcc/c-family/c-common.c",
12896, __FUNCTION__))->decl_minimal.locus))) ? get_location_from_adhoc_loc
(line_table, ((contains_struct_check (((tree)expr), (TS_DECL_MINIMAL),
"/home/msebor/scm/fsf/gcc-66516/gcc/c-family/c-common.c", 12896,
__FUNCTION__))->decl_minimal.locus)) : (((contains_struct_check (((tree)expr),
(TS_DECL_MINIMAL), "/home/msebor/scm/fsf/gcc-66516/gcc/c-family/c-common.c",
12896, __FUNCTION__))->decl_minimal.locus))) <= ((source_location) 1))
(gdb) p DECL_IS_BUILTIN((tree)expr)
Cannot resolve function contains_struct_check to any overloaded instance

Test case:

$ cat t.cpp && gcc -g3 t.cpp && gdb -batch -ex 'b bar' -ex r -ex 'p FOO1(b)'
-ex 'p FOO2(b)' -ex 'p foo((A)b)' -ex 'p foo((A)b) ? foo((A)b) : foo((A)b)'
a.out
struct U { };

typedef U *A;
typedef const U *B;

A foo (A a) { return a; }
B foo (B b) { return b; }

#define FOO1(x) foo ((A)x)
#define FOO2(x) foo (FOO1 (x)) ? foo (FOO1 (x)) : foo (FOO1 (x))

int bar (B b)
{
if (FOO2 (b))
return 1;
return 0;
}

int main ()
{
U u = { };
return bar (&u);
}
Breakpoint 1 at 0x40051e: file t.cpp, line 14.
warning: the debug information found in
"/usr/lib/debug//lib64/ld-2.20.so.debug" does not match
"/lib64/ld-linux-x86-64.so.2" (CRC mismatch).

warning: the debug information found in
"/usr/lib/debug//lib64/libc-2.20.so.debug" does not match "/lib64/libc.so.6"
(CRC mismatch).


Breakpoint 1, bar (b=0x7fffffffdeff) at t.cpp:14
14 if (FOO2 (b))
$1 = (U *) 0x7fffffffdeff
Cannot resolve function foo to any overloaded instance
$2 = (U *) 0x7fffffffdeff
Cannot resolve function foo to any overloaded instance
--
You are receiving this mail because:
You are on the CC list for the bug.
keiths at redhat dot com
2017-03-09 22:09:27 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18881

Keith Seitz <keiths at redhat dot com> changed:

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

--- Comment #1 from Keith Seitz <keiths at redhat dot com> ---
Is this still a problem? This appears to be working since 7.9:

$ ./gdb -ex 'b bar' -ex r -ex 'p FOO1(b)' -ex 'p FOO2(b)' \
-ex 'p foo((A)b)' -ex 'p foo((A)b) ? foo((A)b) : foo((A)b)' ~/tmp/18881

Breakpoint 1, bar (b=0x7fffffffd9bf) at 18881.cc:14
14 if (FOO2 (b))
$1 = (const U *) 0x7fffffffd9bf
$2 = (const U *) 0x7fffffffd9bf
$3 = (const U *) 0x7fffffffd9bf
$4 = (const U *) 0x7fffffffd9bf
(gdb) show version
GNU gdb (GDB) 7.9.1.20150702-cvs
[snip]
--
You are receiving this mail because:
You are on the CC list for the bug.
msebor at gmail dot com
2017-03-11 00:54:23 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18881

Martin Sebor <msebor at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gmail dot com

--- Comment #2 from Martin Sebor <msebor at gmail dot com> ---
It looks fixed in GDB 7.10.1-31.fc23. The output also looks correct (the
"const" in 7.9.1 output, i.e., "(const U *) 0x7fffffffd9bf" does not).

$ gcc -g3 t.cpp && gdb -batch -ex 'b bar' -ex r -ex 'p FOO1(b)' -ex 'p FOO2(b)'
-ex 'p foo((A)b)' -ex 'p foo((A)b) ? foo((A)b) : foo((A)b)' a.out
Breakpoint 1 at 0x40051e: file t.cpp, line 14.

Breakpoint 1, bar (b=0x7fffffffe1af) at t.cpp:14
14 if (FOO2 (b))
$1 = (U *) 0x7fffffffe1af
$2 = (U *) 0x7fffffffe1af
$3 = (U *) 0x7fffffffe1af
$4 = (U *) 0x7fffffffe1af
--
You are receiving this mail because:
You are on the CC list for the bug.
simon.marchi at ericsson dot com
2018-08-20 03:47:08 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18881

Simon Marchi <simon.marchi at ericsson dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |simon.marchi at ericsson dot com
Resolution|--- |FIXED

--- Comment #3 from Simon Marchi <simon.marchi at ericsson dot com> ---
Closing, since this seems fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...