While trying to compile PPL using a gcc that targets Win64, an autoconf test for a "remainder" bug fails. The test basically tries to compute INT_MIN % -1. The program compiles cleanly, but execution results in a crash with exit code 149. The compile line is without any -O optimization, and with a single -f option: g++ -frounding-math a.cpp The test is as follows: #include <climits> int minus_one(int n) { return (n+1)*(n-1)-n*n; } int p(int x, int y) { int z = x % y; return z; } int main(int argc, char** argv) { if (p(INT_MIN, minus_one(argc)) != 0) return 1; else return 0; }
INT_MIN % -1 is undefined as INT_MIN/-1 is undefined. The reason why INT_MIN/-1 is undefined is because - INT_MIN overflows. So this is not a GCC bug but a PPL bug. Report this to them.
Re-opening, valid PR as per 30484. Will close as duplicate.
Marking as duplicate of 30484. *** This bug has been marked as a duplicate of 30484 ***