GCC 4.3.2 bug (was: Illegal subtraction in tmp-dive_1.s)

Gabriel Dos Reis gdr at integrable-solutions.net
Fri Apr 17 19:09:42 CEST 2009


At least, let's get it archived on GCC mailing lists.

On Fri, Apr 17, 2009 at 11:25 AM, Torbjorn Granlund <tg at gmplib.org> wrote:
> Vincent Lefevre <vincent at vinc17.org> writes:
>
>  FYI, here's a simple testcase:
>
>  /* With GCC 4.3.2 and -O2 option: output value is 1 instead of 0.
>   * If -fno-strict-aliasing is added, this bug disappears.
>   */
>
>  #include <stdio.h>
>  #include <stdlib.h>
>
>  int test (int n)
>  {
>    unsigned long *p, *q;
>    int i;
>
>    q = p = malloc (n * sizeof (unsigned long));
>    if (p == NULL)
>      return 2;
>    for (i = 0; i < n - 1; i++)
>      p[i] = 0;
>    p[n - 1] = 1;
>    while ((*(q++))-- == 0) ;
>    return p[n - 1] == 1;
>  }
>
>  int main (void)
>  {
>    int r;
>
>    r = test (17);
>    printf ("%d\n", r);
>    return r;
>  }
>
>  You may want to use it in configure to detect the bug there (as not
>  all users run "make check"). Possibly add -fno-strict-aliasing if
>  the bug is detected.
>
> Nice.  I think that test should go onto the GCC testsuite.
>
> I suppose a problem is that the code wrt GMP need to be *executed*;
> configure feature tests should work also when cross-compiling, I think.
>
> --
> Torbjörn
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>


More information about the gmp-discuss mailing list