This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug tree-optimization/67953] New: [6 Regression] match.pd: X - (X / Y) * Y wrong on change of sign


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67953

            Bug ID: 67953
           Summary: [6 Regression] match.pd: X - (X / Y) * Y wrong on
                    change of sign
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

$ cat z.c
#include <stdio.h>
unsigned f(signed a){
  return (unsigned)a-((a/3)*3);
}
unsigned g(signed a){
  return a-((a/3)*3);
}
int main(){
  printf("%d %d\n", f(-5), g(-5));
}
$ gcc-5 z.c && ./a.out
-2 -2
$ clang z.c && ./a.out       
-2 -2
$ gcc-snapshot z.c && ./a.out 
2 -2


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