tdep/2075: incorrect return value when bool functions are printed on amd64
Fri Jan 27 21:48:00 GMT 2006

>Number:         2075
>Category:       tdep
>Synopsis:       incorrect return value when bool functions are printed on amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 27 21:48:01 GMT 2006
>Originator:     Woody LaRue
>Release:        gdb-6.3
amd64 / linux
printing a function that returns a bool value always returns false.

cat test.cpp
bool test()
  return true;

main(int, char**)
sdvopt05{larue 60}:!g++
g++ -g test.cpp
sdvopt05{larue 61}:gdb a.out
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...Using host libthread_db library "/lib64/tls/".

(gdb) run
Starting program: /home/larue/a.out 


Program received signal SIGINT, Interrupt.
main () at test.cpp:8
8       while(1);
(gdb) print test()
$1 = false
I have a fix to the function amd64_classify function (add TYPE_CODE_BOOL to the test clause)

static void
amd64_classify (struct type *type, enum amd64_reg_class class[2])
  enum type_code code = TYPE_CODE (type);
  int len = TYPE_LENGTH (type);

  class[0] = class[1] = AMD64_NO_CLASS;

  /* Arguments of types (signed and unsigned) _Bool, char, short, int,
     long, long long, and pointers are in the INTEGER class.  Similarly,
     range types, used by languages such as Ada, are also in the INTEGER
     class.  */

 /* Adding TYPE_CODE_BOOL to the following test. Without this printing a boolean 
    valued function is incorrectly returning false. 1/27/06  */
  if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM
       || code == TYPE_CODE_RANGE
       || code == TYPE_CODE_PTR || code == TYPE_CODE_REF || TYPE_CODE_BOOL)
      && (len == 1 || len == 2 || len == 4 || len == 8))
    class[0] = AMD64_INTEGER;


More information about the Gdb-prs mailing list