<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Unable to call K&R declared function with float arguments in debugger after 6c9559b67b91966bfeff9e17808a3e84a92e64a0"
href="https://bugs.llvm.org/show_bug.cgi?id=51034">51034</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unable to call K&R declared function with float arguments in debugger after 6c9559b67b91966bfeff9e17808a3e84a92e64a0
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>douglas_yung@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Internally we run the GDB test suite and a couple of tests in there started
failing recently which I bisected to commit
6c9559b67b91966bfeff9e17808a3e84a92e64a0. The root of the problem seems to be
that after 6c9559b67, when trying to invoke a function from a debugging session
in gdb, if the function was declared in a K&R style, it does not seem to pass
float arguments to the function being called.
For example, consider the following code:
/* test.c */
#include <stdio.h>
#define DELTA (0.001)
float float_val1 = 3.14159;
float float_val2 = -2.3765;
int t_float_values (float_arg1, float_arg2)
float float_arg1, float_arg2;
{
printf("float_arg1 = %f, float_arg2 = %f\n", float_arg1, float_arg2);
return ((float_arg1 - float_val1) < DELTA
&& (float_arg1 - float_val1) > -DELTA
&& (float_arg2 - float_val2) < DELTA
&& (float_arg2 - float_val2) > -DELTA);
}
int foo1() {
return t_float_values(3.14159,-2.3765);
}
int main(int argc, char *argv[]) {
return foo1();
}
/* test.c */
If you compile that code with debug information and then debug the binary using
gdb with the following commands, you can see the problem:
1. b main
2. r
3. p foo1()
4. p t_float_values(3.14159,-2.3765)
The return value of the commands in 3 and 4 should be the same. When test.c is
compiled with a compiler prior to 6c9559b67, that is indeed the case. But if
compiled with a compiler that includes 6c9559b67, the return value of 4 is 0
instead of 1 like it should be. Additionally, from the printf() statement, you
can see that the values of float_arg1 and float_arg2 are not being passed into
the function when it is invoked in 4.
GDB session using binary built by a "good" compiler:
Reading symbols from test.good.elf...
(gdb) b main
Breakpoint 1 at 0x401266: file test.c, line 23.
(gdb) r
Starting program: /home/dyung/sandbox/gdb/test.good.elf
Breakpoint 1, main (argc=1, argv=0x7fffffffe458) at test.c:23
23 return foo1();
(gdb) p foo1()
float_arg1 = 3.141590, float_arg2 = -2.376500
$1 = 1
(gdb) p t_float_values(3.14159,-2.3765)
float_arg1 = 3.141590, float_arg2 = -2.376500
$2 = 1
GDB session using binary built by a "bad" compiler:
Reading symbols from test.bad.elf...
(gdb) b main
Breakpoint 1 at 0x401266: file test.c, line 23.
(gdb) r
Starting program: /home/dyung/sandbox/gdb/test.bad.elf
Breakpoint 1, main (argc=1, argv=0x7fffffffe458) at test.c:23
23 return foo1();
(gdb) p foo1()
float_arg1 = 3.141590, float_arg2 = -2.376500
$1 = 1
(gdb) p t_float_values(3.14159,-2.3765)
float_arg1 = 0.000000, float_arg2 = 0.000000
$2 = 0</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>