------- Comment #3 from pinskia at gcc dot gnu dot org  2007-03-12 06:11 -------
How about:
extern void link_error ();
void foo (int a)
{
  if (a < 0)
    {
      int y;
      a *=-2;
      y  = a / 7;
      if (y > 1 << 30)
        link_error ();
    }
}

int main()
{
  return 0;
}

Also?  Which is like the below testcase but is not just a = -a;

In fact it is weird to have:
extern void link_error ();
void foo (int a)
{
  if (a < 0)
    {
      int y;
      y  = -a / 7;
      if (y > 1 << 30)
        link_error ();
    }
}

Work and not the testcase in comment #0 to work :)  In fact -Wstrict-overflow
does not even warn about the above testcase :), even though the transformation
between -a / 7 to a/-7 dependings on integer overflow being undefined.  Looks
like someone missed a case in fold-const.c :).  (note I added it so I
remembered about it). 


-- 


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

Reply via email to