Bug 14757 - Print of expressions with no debug information gives wrong results
Summary: Print of expressions with no debug information gives wrong results
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-23 21:28 UTC by Jonas Wagner
Modified: 2012-10-23 21:28 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Example program showing different types of functions (150 bytes, text/x-c++src)
2012-10-23 21:28 UTC, Jonas Wagner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Wagner 2012-10-23 21:28:07 UTC
Created attachment 6696 [details]
Example program showing different types of functions

When I print expressions involving functions for which no debug information is available, the result is wrong.

Consider the attached example program, and the following gdb session:

(gdb) print sqrt
$1 = {<text variable, no debug info>} 0x7ffff7879010 <sqrt>
(gdb) print std::sqrt
No symbol "sqrt" in namespace "std".
(gdb) print mysqrt
$2 = {double (double)} 0x40083c <mysqrt(double)>
(gdb) print sqrt(0.5)
$3 = 0
(gdb) print std::sqrt(0.5)
No symbol "sqrt" in namespace "std".
(gdb) print mysqrt(0.5)
$4 = 0.25

I would expect the call "print sqrt(0.5)" to give an error message indicating that the expression cannot be printed due to missing debug information. Giving a wrong result without any indication that something is wrong is... wrong.

Also, I'm puzzled as to why "print std::sqrt(0.5)" fails, given that the program compiles (so std::sqrt apparently exists).

There is a related StackOverflow question at http://stackoverflow.com/questions/5122570/why-does-gdb-evaluate-sqrt3-to-0