t-export fails for 4.2.1

Torbjorn Granlund tege at swox.com
Tue Jun 13 12:12:32 CEST 2006


Laurent Fousse <laurent at komite.net> writes:

  Yup. I expected someone on the list would have an idea and perhaps
  provide a minimal test case for the compiler. I intend to do that
  myself, but not before next week.

I hacked down the test case to the code below.  It should be fairly
simple to provide a dummy mpz_export to make this self-contained.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "tests.h"

void
check_data (void)
{
  static const struct {
    const char  *src;
    size_t      want_count;
    int         order;
    size_t      size;
    int         endian;
    int         nail;
    char        want_data[64];
  } data[] = {
    { "0", 0,1, 1,1, 0 },
    { "0", 0,1, 2,1, 0 },
  };

  char    buf[sizeof(data[0].src) + sizeof (mp_limb_t) + 128];
  char    *got_data;
  size_t  align, got_count, j;
  int     i;
  mpz_t   src;

  mpz_init (src);

  for (i = 0; i < numberof (data); i++)
    {
      for (align = 0; align < sizeof (mp_limb_t); align++)
        {
          mpz_set_str (src, data[i].src, 0);
          MPZ_CHECK_FORMAT (src);
          got_data = buf + align;

          memset (got_data, '\0', data[i].want_count * data[i].size);
          mpz_export (got_data, &got_count, data[i].order,
		      data[i].size, data[i].endian, data[i].nail, src);

          if (memcmp (got_data, data[i].want_data, got_count*data[i].size))
            {
              for (j = 0; j < data[i].want_count*data[i].size; j++)
                printf ("hello world");
              abort ();
            }
        }
    }
  mpz_clear (src);
}

int
main (void)
{
  tests_start ();

  mp_trace_base = -16;
  check_data ();

  tests_end ();
  exit (0);
}

-- 
Torbjörn


More information about the gmp-bugs mailing list