From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Partain To: gcc-gnats@gcc.gnu.org Subject: c/3823: gcc 3.0 on sparc-solaris2.6 ICE on gimp-1.0.4 rect.c Date: Wed, 25 Jul 2001 13:56:00 -0000 Message-id: <200107252047.VAA27755@slicker.dcs.gla.ac.uk> X-SW-Source: 2001-07/msg00688.html List-Id: >Number: 3823 >Category: c >Synopsis: gcc 3.0 on sparc-solaris2.6 ICE on gimp-1.0.4 rect.c >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Wed Jul 25 13:56:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Will Partain >Release: 3.0 >Organization: >Environment: System: SunOS slicker 5.6 Generic_105181-25 sun4u sparc SUNW,Ultra-5_10 Architecture: sun4 host: sparc-sun-solaris2.6 build: sparc-sun-solaris2.6 target: sparc-sun-solaris2.6 configured with: ./configure --prefix=/.-ark-deploy/gcc--3.0 --enable-languages=c,c++ --disable-nls : (reconfigured) ./configure --prefix=/.-ark-deploy/gcc--3.0 --enable-languages=c,c++ --disable-nls >Description: compiling with -O2 -fstrict-aliasing yields ICE; this is rect.c from gimp-1.0.4 >How-To-Repeat: === beginning of .i typedef struct { int quot; int rem; } div_t; typedef struct { long quot; long rem; } ldiv_t; typedef struct { long long quot; long long rem; } lldiv_t; typedef unsigned int size_t; typedef long uid_t; typedef long int wchar_t; extern unsigned char __ctype[]; extern double atof(const char *); extern int atoi(const char *); extern long int atol(const char *); extern double strtod(const char *, char **); extern long int strtol(const char *, char **, int); extern unsigned long int strtoul(const char *, char **, int); extern int rand(void); extern void srand(unsigned int); extern void *calloc(size_t, size_t); extern void free(void *); extern void *malloc(size_t); extern void *realloc(void *, size_t); extern void abort(void); extern int atexit(void (*)(void)); extern void exit(int); extern void _exithandle(void); extern char *getenv(const char *); extern int system(const char *); extern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); extern int abs(int); extern div_t div(int, int); extern long int labs(long); extern ldiv_t ldiv(long, long); extern int mbtowc(wchar_t *, const char *, size_t); extern int mblen(const char *, size_t); extern int wctomb(char *, wchar_t); extern size_t mbstowcs(wchar_t *, const char *, size_t); extern size_t wcstombs(char *, const wchar_t *, size_t); extern double drand48(void); extern double erand48(unsigned short *); extern long jrand48(unsigned short *); extern void lcong48(unsigned short *); extern long lrand48(void); extern long mrand48(void); extern long nrand48(unsigned short *); extern unsigned short *seed48(unsigned short *); extern void srand48(long); extern int putenv(const char *); extern void setkey(const char *); extern void swab(const char *, char *, int); extern int mkstemp(char *); extern int mkstemp64(char *); extern long a64l(const char *); extern char *ecvt(double, int, int *, int *); extern char *fcvt(double, int, int *, int *); extern char *gcvt(double, int, char *); extern int getsubopt(char **, char *const *, char **); extern int grantpt(int); extern char *initstate(unsigned, char *, size_t); extern char *l64a(long); extern char *mktemp(char *); extern char *ptsname(int); extern long random(void); extern char *realpath(const char *, char *); extern char *setstate(const char *); extern void srandom(unsigned); extern int ttyslot(void); extern int unlockpt(int); extern void *valloc(size_t); extern int dup2(int, int); extern char *qecvt(long double, int, int *, int *); extern char *qfcvt(long double, int, int *, int *); extern char *qgcvt(long double, int, char *); extern char *getcwd(char *, size_t); extern const char *getexecname(void); extern char *getlogin(void); extern int getopt(int, char *const *, const char *); extern char *optarg; extern int optind, opterr, optopt; extern char *getpass(const char *); extern char *getpassphrase(const char *); extern int getpw(uid_t, char *); extern int isatty(int); extern void *memalign(size_t, size_t); extern char *ttyname(int); extern long long atoll(const char *); extern long long llabs(long long); extern lldiv_t lldiv(long long, long long); extern char *lltostr(long long, char *); extern long long strtoll(const char *, char **, int); extern unsigned long long strtoull(const char *, char **, int); extern char *ulltostr(unsigned long long, char *); typedef __builtin_va_list __gnuc_va_list; typedef void *__va_list; typedef long long __longlong_t; typedef long off_t; typedef __longlong_t off64_t; typedef long fpos_t; typedef __longlong_t fpos64_t; typedef struct { int _cnt; unsigned char *_ptr; unsigned char *_base; unsigned char _flag; unsigned char _file; } FILE; extern FILE __iob[20]; extern FILE *_lastbuf; extern unsigned char *_bufendtab[]; extern unsigned char _sibuf[], _sobuf[]; extern int remove(const char *); extern int rename(const char *, const char *); extern FILE *tmpfile(void); extern char *tmpnam(char *); extern int fclose(FILE *); extern int fflush(FILE *); extern FILE *fopen(const char *, const char *); extern FILE *freopen(const char *, const char *, FILE *); extern void setbuf(FILE *, char *); extern void setbuffer(FILE *, char *, size_t); extern int setlinebuf(FILE *); extern int setvbuf(FILE *, char *, int, size_t); extern int fprintf(FILE *, const char *, ...); extern int fscanf(FILE *, const char *, ...); extern int printf(const char *, ...); extern int scanf(const char *, ...); extern int snprintf(char *, size_t, const char *, ...); extern int sprintf(char *, const char *, ...); extern int sscanf(const char *, const char *, ...); extern int vfprintf(FILE *, const char *, __gnuc_va_list); extern int vprintf(const char *, __gnuc_va_list); extern int vsnprintf(char *, size_t, const char *, __gnuc_va_list); extern int vsprintf(char *, const char *, __gnuc_va_list); extern int fgetc(FILE *); extern char *fgets(char *, int, FILE *); extern int fputc(int, FILE *); extern int fputs(const char *, FILE *); extern int getc(FILE *); extern int getchar(void); extern char *gets(char *); extern int putc(int, FILE *); extern int putchar(int); extern int puts(const char *); extern int ungetc(int, FILE *); extern size_t fread(void *, size_t, size_t, FILE *); extern size_t fwrite(const void *, size_t, size_t, FILE *); extern int fgetpos(FILE *, fpos_t *); extern int fseek(FILE *, long, int); extern int fsetpos(FILE *, const fpos_t *); extern long ftell(FILE *); extern void rewind(FILE *); extern void clearerr(FILE *); extern int feof(FILE *); extern int ferror(FILE *); extern void perror(const char *); extern int __filbuf(FILE *); extern int __flsbuf(int, FILE *); extern FILE *fdopen(int, const char *); extern char *ctermid(char *); extern int fileno(FILE *); extern FILE *popen(const char *, const char *); extern char *cuserid(char *); extern char *tempnam(const char *, const char *); extern int getopt(int, char *const *, const char *); extern int getsubopt(char **, char *const *, char **); extern char *optarg; extern int optind, opterr, optopt; extern int getw(FILE *); extern int putw(int, FILE *); extern int pclose(FILE *); extern int fseeko(FILE *, off_t, int); extern off_t ftello(FILE *); extern FILE *fopen64(const char *, const char *); extern FILE *freopen64(const char *, const char *, FILE *); extern FILE *tmpfile64(void); extern int fgetpos64(FILE *, fpos64_t *); extern int fsetpos64(FILE *, const fpos64_t *); extern int fseeko64(FILE *, off64_t, int); extern off64_t ftello64(FILE *); typedef union _h_val { unsigned long _i[sizeof(double) / sizeof(unsigned long)]; double _d; } _h_val; extern const _h_val __huge_val; extern int signgam; enum version {libm_ieee = -1, c_issue_4, ansi_1, strict_ansi}; extern const enum version _lib_version; struct exception { int type; char *name; double arg1; double arg2; double retval; }; extern double acos (double); extern double asin (double); extern double atan (double); extern double atan2 (double, double); extern double cos (double); extern double sin (double); extern double tan (double); extern double cosh (double); extern double sinh (double); extern double tanh (double); extern double exp (double); extern double frexp (double, int *); extern double ldexp (double, int); extern double log (double); extern double log10 (double); extern double modf (double, double *); extern double pow (double, double); extern double sqrt (double); extern double ceil (double); extern double fabs (double); extern double floor (double); extern double fmod (double, double); extern double erf (double); extern double erfc (double); extern double gamma (double); extern double hypot (double, double); extern int isnan (double); extern double j0 (double); extern double j1 (double); extern double jn (int, double); extern double lgamma (double); extern double y0 (double); extern double y1 (double); extern double yn (int, double); extern double acosh (double); extern double asinh (double); extern double atanh (double); extern double cbrt (double); extern double logb (double); extern double nextafter (double, double); extern double remainder (double, double); extern double scalb (double, double); extern double expm1 (double); extern int ilogb (double); extern double log1p (double); extern double rint (double); extern int matherr (struct exception *); extern double significand (double); extern double copysign (double, double); extern double scalbn (double, int); extern float modff (float, float *); enum fp_direction_type { fp_nearest = 0, fp_tozero = 1, fp_positive = 2, fp_negative = 3 }; enum fp_precision_type { fp_extended = 0, fp_single = 1, fp_double = 2, fp_precision_3 = 3 }; enum fp_exception_type { fp_inexact = 0, fp_division = 1, fp_underflow = 2, fp_overflow = 3, fp_invalid = 4 }; enum fp_trap_enable_type { fp_trap_inexact = 0, fp_trap_division = 1, fp_trap_underflow = 2, fp_trap_overflow = 3, fp_trap_invalid = 4 }; enum fp_class_type { fp_zero = 0, fp_subnormal = 1, fp_normal = 2, fp_infinity = 3, fp_quiet = 4, fp_signaling = 5 }; typedef int sigfpe_code_type; typedef void (*sigfpe_handler_type)(); extern sigfpe_handler_type sigfpe (sigfpe_code_type, sigfpe_handler_type); typedef float single; typedef unsigned extended[3]; typedef long double quadruple; typedef unsigned fp_exception_field_type; typedef char decimal_string[512]; typedef struct { enum fp_class_type fpclass; int sign; int exponent; decimal_string ds; int more; int ndigits; } decimal_record; enum decimal_form { fixed_form, floating_form }; typedef struct { enum fp_direction_type rd; enum decimal_form df; int ndigits; } decimal_mode; enum decimal_string_form { invalid_form, whitespace_form, fixed_int_form, fixed_intdot_form, fixed_dotfrac_form, fixed_intdotfrac_form, floating_int_form, floating_intdot_form, floating_dotfrac_form, floating_intdotfrac_form, inf_form, infinity_form, nan_form, nanstring_form }; extern void single_to_decimal (single *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void double_to_decimal (double *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void extended_to_decimal (extended *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void quadruple_to_decimal (quadruple *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void decimal_to_single (single *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void decimal_to_double (double *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void decimal_to_extended (extended *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void decimal_to_quadruple (quadruple *, decimal_mode *, decimal_record *, fp_exception_field_type *); extern void string_to_decimal (char **, int, int, decimal_record *, enum decimal_string_form *, char **); extern void func_to_decimal (char **, int, int, decimal_record *, enum decimal_string_form *, char **, int (*)(void), int *, int (*)(int)); extern void file_to_decimal (char **, int, int, decimal_record *, enum decimal_string_form *, char **, FILE *, int *); extern char *seconvert (single *, int, int *, int *, char *); extern char *sfconvert (single *, int, int *, int *, char *); extern char *sgconvert (single *, int, int, char *); extern char *econvert (double, int, int *, int *, char *); extern char *fconvert (double, int, int *, int *, char *); extern char *gconvert (double, int, int, char *); extern char *qeconvert (quadruple *, int, int *, int *, char *); extern char *qfconvert (quadruple *, int, int *, int *, char *); extern char *qgconvert (quadruple *, int, int, char *); extern char *ecvt (double, int, int *, int *); extern char *fcvt (double, int, int *, int *); extern char *gcvt (double, int, char *); extern double atof (const char *); extern double strtod (const char *, char **); typedef double clrmap[256][3]; extern void rgb2hsv(double *rgb, double *hsv); extern void hsv2rgb(double *hsv, double *rgb); extern int get_cmap(int n, clrmap c, int cmap_len); typedef double point[3]; typedef struct { double var[7]; double c[3][2]; double density; double color; } xform; typedef struct { xform xform[6]; clrmap cmap; double time; int cmap_index; double brightness; double contrast; double gamma; int width, height; int spatial_oversample; double center[2]; double zoom; double pixels_per_unit; double spatial_filter_radius; double sample_density; int nbatches; int white_level; int cmap_inter; double pulse[2][2]; double wiggle[2][2]; } control_point; extern void iterate(control_point *cp, int n, int fuse, point points[]); extern void interpolate(control_point cps[], int ncps, double time, control_point *result); extern void tokenize(char **ss, char *argv[], int *argc); extern void print_control_point(FILE *f, control_point *cp, int quote); extern void random_control_point(control_point *cp, int ivar); extern void parse_control_point(char **ss, control_point *cp); extern void estimate_bounding_box(control_point *cp, double eps, double *bmin, double *bmax); extern void sort_control_points(control_point *cps, int ncps, double (*metric)()); extern double standard_metric(control_point *cp1, control_point *cp2); extern double random_uniform01(); extern double random_uniform11(); extern double random_gaussian(); extern void mult_matrix(double s1[2][2], double s2[2][2], double d[2][2]); void copy_variation(control_point *cp0, control_point *cp1); typedef struct { double temporal_filter_radius; control_point *cps; int ncps; double time; } frame_spec; extern void render_rectangle(frame_spec *spec, unsigned char *out, int out_width, int field, int nchan, void progress(double)); extern void *memcpy(void *, const void *, size_t); extern void *memmove(void *, const void *, size_t); extern char *strcpy(char *, const char *); extern char *strncpy(char *, const char *, size_t); extern char *strcat(char *, const char *); extern char *strncat(char *, const char *, size_t); extern int memcmp(const void *, const void *, size_t); extern int strcmp(const char *, const char *); extern int strcoll(const char *, const char *); extern int strncmp(const char *, const char *, size_t); extern size_t strxfrm(char *, const char *, size_t); extern void *memchr(const void *, int, size_t); extern char *strchr(const char *, int); extern size_t strcspn(const char *, const char *); extern char *strpbrk(const char *, const char *); extern char *strrchr(const char *, int); extern size_t strspn(const char *, const char *); extern char *strstr(const char *, const char *); extern char *strtok(char *, const char *); extern void *memset(void *, int, size_t); extern char *strerror(int); extern size_t strlen(const char *); extern void *memccpy(void *, const void *, int, size_t); extern char *strsignal(int); extern int ffs(int); extern int strcasecmp(const char *, const char *); extern int strncasecmp(const char *, const char *, size_t); extern char *strdup(const char *); typedef short bucket[4]; typedef short accum_t; typedef accum_t abucket[4]; void normalize_vector(v, n) double *v; int n; { double t = 0.0; int i; for (i = 0; i < n; i++) t += v[i]; t = 1.0 / t; for (i = 0; i < n; i++) v[i] *= t; } void render_rectangle(spec, out, out_width, field, nchan, progress) frame_spec *spec; unsigned char *out; int out_width; int field; int nchan; void progress(double); { int i, j, k, nsamples, nbuckets, batch_size, batch_num, sub_batch; bucket *buckets; abucket *accumulate; point *points; double *filter, *temporal_filter, *temporal_deltas; double bounds[4], size[2], ppux, ppuy; int image_width, image_height; int width, height; int filter_width; int oversample = spec->cps[0].spatial_oversample; int nbatches = spec->cps[0].nbatches; bucket cmap[256]; int gutter_width; int sbc; image_width = spec->cps[0].width; if (field) { image_height = spec->cps[0].height / 2; if (field == 2) out += nchan * out_width; out_width *= 2; } else image_height = spec->cps[0].height; if (1) { filter_width = (2.0 * 2.5 * oversample * spec->cps[0].spatial_filter_radius); if ((filter_width ^ oversample) & 1) filter_width++; filter = (double *) malloc(sizeof(double) * filter_width * filter_width); for (i = 0; i < filter_width; i++) for (j = 0; j < filter_width; j++) { double ii = ((2.0 * i + 1.0) / filter_width - 1.0) * 2.5; double jj = ((2.0 * j + 1.0) / filter_width - 1.0) * 2.5; if (field) jj *= 2.0; filter[i + j * filter_width] = exp(-2.0 * (ii * ii + jj * jj)); } normalize_vector(filter, filter_width * filter_width); } temporal_filter = (double *) malloc(sizeof(double) * nbatches); temporal_deltas = (double *) malloc(sizeof(double) * nbatches); if (nbatches > 1) { double t; for (i = 0; i < nbatches; i++) { t = temporal_deltas[i] = (2.0 * ((double) i / (nbatches - 1)) - 1.0) * spec->temporal_filter_radius; temporal_filter[i] = exp(-2.0 * t * t); } normalize_vector(temporal_filter, nbatches); } else { temporal_filter[0] = 1.0; temporal_deltas[0] = 0.0; } gutter_width = (filter_width - oversample) / 2; height = oversample * image_height + 2 * gutter_width; width = oversample * image_width + 2 * gutter_width; nbuckets = width * height; if (1) { static char *last_block = 0; static int last_block_size = 0; int memory_rqd = (sizeof(bucket) * nbuckets + sizeof(abucket) * nbuckets + sizeof(point) * 10000); if (memory_rqd > last_block_size) { if (last_block != 0) free(last_block); last_block = (char *) malloc(memory_rqd); if (0 == last_block) { fprintf((&__iob[2]), "render_rectangle: cannot malloc %d bytes.\n", memory_rqd); exit(1); } last_block_size = memory_rqd; } buckets = (bucket *) last_block; accumulate = (abucket *) (last_block + sizeof(bucket) * nbuckets); points = (point *) (last_block + (sizeof(bucket) + sizeof(abucket)) * nbuckets); } memset((char *) accumulate, 0, sizeof(abucket) * nbuckets); for (batch_num = 0; batch_num < nbatches; batch_num++) { double batch_time; double sample_density; control_point cp; memset((char *) buckets, 0, sizeof(bucket) * nbuckets); batch_time = spec->time + temporal_deltas[batch_num]; interpolate(spec->cps, spec->ncps, batch_time, &cp); for (j = 0; j < 256; j++) { for (k = 0; k < 3; k++) { cmap[j][k] = (int) (cp.cmap[(j * 256) / 256][k] * cp.white_level); } cmap[j][3] = cp.white_level; } if (1) { double t0, t1, shift, corner0, corner1; double scale; scale = pow(2.0, cp.zoom); sample_density = cp.sample_density * scale * scale; ppux = cp.pixels_per_unit * scale; ppuy = field ? (ppux / 2.0) : ppux; switch (field) { case 0: shift = 0.0; break; case 1: shift = -0.5; break; case 2: shift = 0.5; break; } shift = shift / ppux; t0 = (double) gutter_width / (oversample * ppux); t1 = (double) gutter_width / (oversample * ppuy); corner0 = cp.center[0] - image_width / ppux / 2.0; corner1 = cp.center[1] - image_height / ppuy / 2.0; bounds[0] = corner0 - t0; bounds[1] = corner1 - t1 + shift; bounds[2] = corner0 + image_width / ppux + t0; bounds[3] = corner1 + image_height / ppuy + t1 + shift; size[0] = 1.0 / (bounds[2] - bounds[0]); size[1] = 1.0 / (bounds[3] - bounds[1]); } nsamples = (int) (sample_density * nbuckets / (oversample * oversample)); batch_size = nsamples / cp.nbatches; sbc = 0; for (sub_batch = 0; sub_batch < batch_size; sub_batch += 10000) { if (progress&&!(sbc++&7)) (*progress)(0.5*sub_batch/(double)batch_size); points[0][0] = random_uniform11(); points[0][1] = random_uniform11(); points[0][2] = random_uniform01(); iterate(&cp, 10000, 15, points); for (j = 0; j < 10000; j++) { int k, color_index; double *p = points[j]; bucket *b; if (p[0] < bounds[0] || p[1] < bounds[1] || p[0] > bounds[2] || p[1] > bounds[3]) continue; color_index = (int) (p[2] * 256); if (color_index < 0) color_index = 0; else if (color_index > (256 -1)) color_index = 256 -1; b = buckets + (int) (width * (p[0] - bounds[0]) * size[0]) + width * (int) (height * (p[1] - bounds[1]) * size[1]); for (k = 0; k < 4; k++) { short tt_ = b[0][k] + cmap[color_index][k]; if (tt_ > b[0][k]) b[0][k] = tt_; }; } } if (1) { double k1 =(cp.contrast * cp.brightness * ((1<<14)>>4) * 268.0 * temporal_filter[batch_num]) / 256; double area = image_width * image_height / (ppux * ppuy); double k2 = (oversample * oversample * nbatches) / (cp.contrast * area * cp.white_level * sample_density); for (j = 0; j < height; j++) for (i = 0; i < width; i++) { abucket *a = accumulate + i + j * width; bucket *b = buckets + i + j * width; double c[4], ls; c[0] = (double) b[0][0]; c[1] = (double) b[0][1]; c[2] = (double) b[0][2]; c[3] = (double) b[0][3]; if (0.0 == c[3]) continue; ls = (k1 * log(1.0 + c[3] * k2))/c[3]; c[0] *= ls; c[1] *= ls; c[2] *= ls; c[3] *= ls; { accum_t tt_ = a[0][0] + c[0] + 0.5; if (tt_ > a[0][0]) a[0][0] = tt_; }; { accum_t tt_ = a[0][1] + c[1] + 0.5; if (tt_ > a[0][1]) a[0][1] = tt_; }; { accum_t tt_ = a[0][2] + c[2] + 0.5; if (tt_ > a[0][2]) a[0][2] = tt_; }; { accum_t tt_ = a[0][3] + c[3] + 0.5; if (tt_ > a[0][3]) a[0][3] = tt_; }; } } } if (1) { int x, y; double t[4]; double g = 1.0 / spec->cps[0].gamma; y = 0; for (j = 0; j < image_height; j++) { if (progress && !(j&15)) (*progress)(0.5+0.5*j/(double)image_height); x = 0; for (i = 0; i < image_width; i++) { int ii, jj, a; unsigned char *p; t[0] = t[1] = t[2] = t[3] = 0.0; for (ii = 0; ii < filter_width; ii++) for (jj = 0; jj < filter_width; jj++) { double k = filter[ii + jj * filter_width]; abucket *a = accumulate + x + ii + (y + jj) * width; t[0] += k * a[0][0]; t[1] += k * a[0][1]; t[2] += k * a[0][2]; t[3] += k * a[0][3]; } p = out + nchan * (i + j * out_width); a = 256.0 * pow((double) t[0] / ((1<<14)>>4), g) + 0.5; if (a < 0) a = 0; else if (a > 255) a = 255; p[0] = a; a = 256.0 * pow((double) t[1] / ((1<<14)>>4), g) + 0.5; if (a < 0) a = 0; else if (a > 255) a = 255; p[1] = a; a = 256.0 * pow((double) t[2] / ((1<<14)>>4), g) + 0.5; if (a < 0) a = 0; else if (a > 255) a = 255; p[2] = a; if (nchan > 3) { a = 256.0 * pow((double) t[3] / ((1<<14)>>4), g) + 0.5; if (a < 0) a = 0; else if (a > 255) a = 255; p[3] = a; } x += oversample; } y += oversample; } } free(filter); } === end of .i >Fix: >Release-Note: >Audit-Trail: >Unformatted: