This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Boolean equality (C++/Fortran)


In valarith.c:value_binop, where v1 and v2 have been established to be
values of type bool, we have:

       case BINOP_EQUAL:
          v = v1 == v2;
          break;
          
        case BINOP_NOTEQUAL:
          v = v1 != v2;
	  break;

Isn't this wrong?  If you are mixing your compilers, then, at least for
Fortran, the actual value of true can vary (1 or -1 I have so far
seen).  For C++ this is less likely to happen, and so far as I can tell
changing the above would not harm anything.  

Does anyone have any comments on replacing the above with:

       case BINOP_EQUAL:
          v = !((!v1 && v2) || (v1 && !v2));
          break;
          
        case BINOP_NOTEQUAL:
          v = (!v1 && v2) || (v1 && !v2);
	  break;


d.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]