Bug 37503 - autoconf detects g++ as having a remainder bug
Summary: autoconf detects g++ as having a remainder bug
Status: RESOLVED DUPLICATE of bug 30484
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-12 20:10 UTC by nightstrike
Modified: 2008-09-12 20:32 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nightstrike 2008-09-12 20:10:07 UTC
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;
}
Comment 1 Andrew Pinski 2008-09-12 20:17:48 UTC
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.
Comment 2 nightstrike 2008-09-12 20:32:27 UTC
Re-opening, valid PR as per 30484.  Will close as duplicate.
Comment 3 nightstrike 2008-09-12 20:32:57 UTC
Marking as duplicate of 30484.

*** This bug has been marked as a duplicate of 30484 ***