[Bug middle-end/46679] New: fold_binary changes types in divisionm breaking configure -enable-checking

jay.krell at cornell dot edu gcc-bugzilla@gcc.gnu.org
Sat Nov 27 01:09:00 GMT 2010


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46679

           Summary: fold_binary changes types in divisionm breaking
                    configure -enable-checking
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jay.krell@cornell.edu


fold_binary seemingly changes the types of division inputs (but not the
output),
leading to configure -enable-checking to fail.


My code is something like this (using a different frontend
and slightly patched 4.5.1 but I don't think relevantly):


long a;

long F(void)
{
 return a / a;
}

configure -enable-checking=fold,...:

gcc-4.5
fold-const.c

fold_binary_loc(code = FLOOR_DIV_EXPR,
                op0, op1, type all int_64


arg0, arg1 become word_64
(not op0, op1, but arg0, arg1)


and then we end up here:

      if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR)
      && multiple_of_p (type, arg0, arg1))
    return fold_build2_loc (loc, EXACT_DIV_EXPR, type, arg0, arg1);


and then:


error: type mismatch in binary expression
int_64
word_64
word_64


D.1003 = D.1001 /[ex] D.1002;


multiple_of_p is true because the operands are the same.
 (This would optimize to 1, unless the operands might be 0.)


I'll see if I can reproduce with unpatched C 4.5.1 and trunk.


 - Jay



More information about the Gcc-bugs mailing list