[Bug c/13741] New: Variable-length arrays broke in gcc 3.x?

dmarkuson at arrayinc dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 19 15:14:00 GMT 2004


Program using variable (run-time-sized) arrays (along with nested functions)
worked nicely in gcc 2.95 (linux i686) but fails to compile in unmodified
gcc 3.3.1 (and 3.2) -- compiler faults.  Problem reproduces easily (for me
anyway).

Attached below are build info, actual results, expected results, and
preprocessed source file (standalone other than stdio.h and stdlib.h).

(Didn't fill in the triplets because not sure what is requested and the how-to
instructions didn't elaborate on these fields at all.)

..Don Markuson
  dmarkuson@arrayinc.com

-------------
 * To build and run:
 *
 *  % gcc -o gnu-bug gnu-bug.c
 *  % ./gnu-bug
 *
 * Using unmodified gcc "3.2 20020927 (prerelease)" or "3.3.1 (cygming special)"
 * under cygwin, or gcc 3.3 on RedHat Linux 9 (Intel platform), compiler faults:
 *
 * gnu-bug.c: In function `print_data_blk':
 * gnu-bug.c:253: Internal compiler error in expand_expr, at expr.c:6437
 * Please submit a full bug report.
 * with preprocessed source if appropriate.
 * See <URL://www.gnu.org/software/gcc/bugs.html> for instructions.
 *
 * Using older unmodified gcc "egcs-2.91.66" or "2.95.3" on RedHat Linux 6.2
 * (Intel platform), proper output results:
 *
 * TBL  s21:
 * TBL  s21 season_info_field    = TRUE
 * TBL  s21 date_time_field      = TRUE
 * TBL  s21 demand_reset_ctr     = TRUE
 * TBL  s21 demand_reset_lock    = TRUE
 * TBL  s21 cum_demand           = TRUE
 * TBL  s21 cont_cum_demand      = FALSE
 * TBL  s21 time_remaining       = TRUE
 * TBL  s21 self_read_inh_ovf    = FALSE
 * TBL  s21 self_read_seq_nbr    = FALSE
 * TBL  s21 daily_self_read      = FALSE
 * TBL  s21 weekly_self_read     = FALSE
 * TBL  s21 read_demand_reset    = 1
 * TBL  s21 nbr_self_reads       = 12
 * TBL  s21 nbr_summations       = 5
 * TBL  s21 nbr_demands          = 5
 * TBL  s21 nbr_coin_values      = 10
 * TBL  s21 nbr_occur            = 1
 * TBL  s21 nbr_tiers            = 4
 * TBL  s21 nbr_present_demands  = 0
 * TBL  s21 nbr_present_values   = 0
 * TBL  s24:
 * TBL  s24 season               = 69
 * TBL  s24 prev_season_reg_data:
 * TBL  s24 nbr_demand_resets    = 0
 * TBL  s24 tot_data_block       =
 * TBL  s24   summations[0]      = 0
 * TBL  s24   summations[1]      = 0
 * TBL  s24   summations[2]      = 0
 * TBL  s24   summations[3]      = 0
 * TBL  s24   summations[4]      = 0
 * TBL  s24   demands[0].cum     = 0
 * TBL  s24   demands[0][  0]    = 0         
 * TBL  s24   demands[1].cum     = 0
 * TBL  s24   demands[1][  0]    = 0         
 * TBL  s24   demands[2].cum     = 0
 * TBL  s24   demands[2][  0]    = 0         
 * TBL  s24   demands[3].cum     = 0
 * TBL  s24   demands[3][  0]    = 0         
 * TBL  s24   demands[4].cum     = 0
 * TBL  s24   demands[4][  0]    = 0         
 * TBL  s24   coincidents[0][  0]= 0
 * TBL  s24   coincidents[1][  0]= 0
 * TBL  s24   coincidents[2][  0]= 0
 * TBL  s24   coincidents[3][  0]= 0
 * TBL  s24   coincidents[4][  0]= 0
 * TBL  s24   coincidents[5][  0]= 0
 * TBL  s24   coincidents[6][  0]= 0
 * TBL  s24   coincidents[7][  0]= 0
 * TBL  s24   coincidents[8][  0]= 0
 * TBL  s24   coincidents[9][  0]= 0
 * TBL  s24 tier_data_block[0]   =
 * TBL  s24   summations[0]      = 0
 * TBL  s24   summations[1]      = 0
 * TBL  s24   summations[2]      = 0
 * TBL  s24   summations[3]      = 0
 * TBL  s24   summations[4]      = 0
 * TBL  s24   demands[0].cum     = 0
 * TBL  s24   demands[0][  0]    = 0         
 * TBL  s24   demands[1].cum     = 0
 * TBL  s24   demands[1][  0]    = 0         
 * TBL  s24   demands[2].cum     = 0
 * TBL  s24   demands[2][  0]    = 0         
 * TBL  s24   demands[3].cum     = 0
 * TBL  s24   demands[3][  0]    = 0         
 * TBL  s24   demands[4].cum     = 0
 * TBL  s24   demands[4][  0]    = 0         
 * TBL  s24   coincidents[0][  0]= 0
 * TBL  s24   coincidents[1][  0]= 0
 * TBL  s24   coincidents[2][  0]= 0
 * TBL  s24   coincidents[3][  0]= 0
 * TBL  s24   coincidents[4][  0]= 0
 * TBL  s24   coincidents[5][  0]= 0
 * TBL  s24   coincidents[6][  0]= 0
 * TBL  s24   coincidents[7][  0]= 0
 * TBL  s24   coincidents[8][  0]= 0
 * TBL  s24   coincidents[9][  0]= 0
 * TBL  s24 tier_data_block[1]   =
 * TBL  s24   summations[0]      = 0
 * TBL  s24   summations[1]      = 0
 * TBL  s24   summations[2]      = 0
 * TBL  s24   summations[3]      = 0
 * TBL  s24   summations[4]      = 0
 * TBL  s24   demands[0].cum     = 0
 * TBL  s24   demands[0][  0]    = 0         
 * TBL  s24   demands[1].cum     = 0
 * TBL  s24   demands[1][  0]    = 0         
 * TBL  s24   demands[2].cum     = 0
 * TBL  s24   demands[2][  0]    = 0         
 * TBL  s24   demands[3].cum     = 0
 * TBL  s24   demands[3][  0]    = 0         
 * TBL  s24   demands[4].cum     = 0
 * TBL  s24   demands[4][  0]    = 0         
 * TBL  s24   coincidents[0][  0]= 0
 * TBL  s24   coincidents[1][  0]= 0
 * TBL  s24   coincidents[2][  0]= 0
 * TBL  s24   coincidents[3][  0]= 0
 * TBL  s24   coincidents[4][  0]= 0
 * TBL  s24   coincidents[5][  0]= 0
 * TBL  s24   coincidents[6][  0]= 0
 * TBL  s24   coincidents[7][  0]= 0
 * TBL  s24   coincidents[8][  0]= 0
 * TBL  s24   coincidents[9][  0]= 0
 * TBL  s24 tier_data_block[2]   =
 * TBL  s24   summations[0]      = 0
 * TBL  s24   summations[1]      = 0
 * TBL  s24   summations[2]      = 0
 * TBL  s24   summations[3]      = 0
 * TBL  s24   summations[4]      = 0
 * TBL  s24   demands[0].cum     = 0
 * TBL  s24   demands[0][  0]    = 0         
 * TBL  s24   demands[1].cum     = 0
 * TBL  s24   demands[1][  0]    = 0         
 * TBL  s24   demands[2].cum     = 0
 * TBL  s24   demands[2][  0]    = 0         
 * TBL  s24   demands[3].cum     = 0
 * TBL  s24   demands[3][  0]    = 0         
 * TBL  s24   demands[4].cum     = 0
 * TBL  s24   demands[4][  0]    = 0         
 * TBL  s24   coincidents[0][  0]= 0
 * TBL  s24   coincidents[1][  0]= 0
 * TBL  s24   coincidents[2][  0]= 0
 * TBL  s24   coincidents[3][  0]= 0
 * TBL  s24   coincidents[4][  0]= 0
 * TBL  s24   coincidents[5][  0]= 0
 * TBL  s24   coincidents[6][  0]= 0
 * TBL  s24   coincidents[7][  0]= 0
 * TBL  s24   coincidents[8][  0]= 0
 * TBL  s24   coincidents[9][  0]= 0
 * TBL  s24 tier_data_block[3]   =
 * TBL  s24   summations[0]      = 0
 * TBL  s24   summations[1]      = 0
 * TBL  s24   summations[2]      = 0
 * TBL  s24   summations[3]      = 0
 * TBL  s24   summations[4]      = 0
 * TBL  s24   demands[0].cum     = 0
 * TBL  s24   demands[0][  0]    = 0         
 * TBL  s24   demands[1].cum     = 0
 * TBL  s24   demands[1][  0]    = 0         
 * TBL  s24   demands[2].cum     = 0
 * TBL  s24   demands[2][  0]    = 0         
 * TBL  s24   demands[3].cum     = 0
 * TBL  s24   demands[3][  0]    = 0         
 * TBL  s24   demands[4].cum     = 0
 * TBL  s24   demands[4][  0]    = 0         
 * TBL  s24   coincidents[0][  0]= 0
 * TBL  s24   coincidents[1][  0]= 0
 * TBL  s24   coincidents[2][  0]= 0
 * TBL  s24   coincidents[3][  0]= 0
 * TBL  s24   coincidents[4][  0]= 0
 * TBL  s24   coincidents[5][  0]= 0
 * TBL  s24   coincidents[6][  0]= 0
 * TBL  s24   coincidents[7][  0]= 0
 * TBL  s24   coincidents[8][  0]= 0
 * TBL  s24   coincidents[9][  0]= 4278190080
-----------

# 1 "gcc-bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gcc-bug.c"
# 1 "gnu-bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gnu-bug.c"
# 184 "gnu-bug.c"
# 1 "/usr/include/stdio.h" 1 3
# 29 "/usr/include/stdio.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 15 "/usr/include/_ansi.h" 3
# 1 "/usr/include/newlib.h" 1 3
# 16 "/usr/include/_ansi.h" 2 3
# 1 "/usr/include/sys/config.h" 1 3



# 1 "/usr/include/machine/ieeefp.h" 1 3
# 5 "/usr/include/sys/config.h" 2 3
# 151 "/usr/include/sys/config.h" 3
# 1 "/usr/include/cygwin/config.h" 1 3
# 152 "/usr/include/sys/config.h" 2 3
# 17 "/usr/include/_ansi.h" 2 3
# 30 "/usr/include/stdio.h" 2 3




# 1 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 203 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef unsigned int size_t;
# 35 "/usr/include/stdio.h" 2 3


# 1 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 1 3
# 44 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 3
typedef __builtin_va_list __gnuc_va_list;
# 38 "/usr/include/stdio.h" 2 3







# 1 "/usr/include/sys/reent.h" 1 3
# 14 "/usr/include/sys/reent.h" 3
# 1 "/usr/include/sys/_types.h" 1 3
# 12 "/usr/include/sys/_types.h" 3
typedef long _off_t;
__extension__ typedef long long _off64_t;


typedef int _ssize_t;





# 1 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 323 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef unsigned int wint_t;
# 23 "/usr/include/sys/_types.h" 2 3


typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;

typedef int _flock_t;
# 15 "/usr/include/sys/reent.h" 2 3




typedef unsigned long __ULong;
# 40 "/usr/include/sys/reent.h" 3
struct _Bigint
{
  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


struct __tm
{
  int __tm_sec;
  int __tm_min;
  int __tm_hour;
  int __tm_mday;
  int __tm_mon;
  int __tm_year;
  int __tm_wday;
  int __tm_yday;
  int __tm_isdst;
};







struct _on_exit_args {
        void * _fnargs[32];
        __ULong _fntypes;

};
# 80 "/usr/include/sys/reent.h" 3
struct _atexit {
        struct _atexit *_next;
        int _ind;
        void (*_fns[32])(void);
        struct _on_exit_args _on_exit_args;
};
# 95 "/usr/include/sys/reent.h" 3
struct __sbuf {
        unsigned char *_base;
        int _size;
};






typedef long _fpos_t;



typedef _off64_t _fpos64_t;
# 160 "/usr/include/sys/reent.h" 3
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;






  void * _cookie;

  _ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf, int _n);
  _ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char
*_buf, int _n);

  _fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t _offset,
int _whence);
  int __attribute__((__cdecl__)) (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;


  struct _reent *_data;



  _flock_t _lock;

};


struct __sFILE64 {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;

  struct _reent *_data;


  void * _cookie;

  _ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf, int _n);
  _ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char
*_buf, int _n);

  _fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t _offset,
int _whence);
  int __attribute__((__cdecl__)) (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _flags2;

  _off64_t _offset;
  _fpos64_t __attribute__((__cdecl__)) (*_seek64) (void * _cookie, _fpos64_t
_offset, int _whence);


  _flock_t _lock;

};
typedef struct __sFILE64 __FILE;




struct _glue
{
  struct _glue *_next;
  int _niobs;
  __FILE *_iobs;
};
# 284 "/usr/include/sys/reent.h" 3
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;




};
# 533 "/usr/include/sys/reent.h" 3
struct _reent
{
  int _errno;




  __FILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void __attribute__((__cdecl__)) (*__cleanup) (struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union
    {
      struct
        {
          unsigned int _unused_rand;
          char * _strtok_last;
          char _asctime_buf[26];
          struct __tm _localtime_buf;
          int _gamma_signgam;
          __extension__ unsigned long long _rand_next;
          struct _rand48 _r48;
          _mbstate_t _mblen_state;
          _mbstate_t _mbtowc_state;
          _mbstate_t _wctomb_state;
          char _l64a_buf[8];
          char _signal_buf[24];
          int _getdate_err;
          _mbstate_t _mbrlen_state;
          _mbstate_t _mbrtowc_state;
          _mbstate_t _mbsrtowcs_state;
          _mbstate_t _wcrtomb_state;
          _mbstate_t _wcsrtombs_state;
        } _reent;



      struct
        {

          unsigned char * _nextf[30];
          unsigned int _nmalloc[30];
        } _unused;
    } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**(_sig_func))(int);




  struct _glue __sglue;
  __FILE __sf[3];
};
# 730 "/usr/include/sys/reent.h" 3
extern struct _reent *_impure_ptr ;

void _reclaim_reent (struct _reent *);






  struct _reent * __attribute__((__cdecl__)) __getreent (void);
# 46 "/usr/include/stdio.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 24 "/usr/include/sys/types.h" 3
typedef short int __int16_t;
typedef unsigned short int __uint16_t;





typedef int __int32_t;
typedef unsigned int __uint32_t;






__extension__ typedef long long __int64_t;
__extension__ typedef unsigned long long __uint64_t;
# 55 "/usr/include/sys/types.h" 3
# 1 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 149 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef int ptrdiff_t;
# 296 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef short unsigned int wchar_t;
# 56 "/usr/include/sys/types.h" 2 3
# 1 "/usr/include/machine/types.h" 1 3
# 36 "/usr/include/machine/types.h" 3
typedef long int __off_t;
typedef int __pid_t;

__extension__ typedef long long int __loff_t;
# 57 "/usr/include/sys/types.h" 2 3
# 78 "/usr/include/sys/types.h" 3
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;



typedef unsigned short ushort;
typedef unsigned int uint;



typedef unsigned long clock_t;




typedef long time_t;




struct timespec {
  time_t tv_sec;
  long tv_nsec;
};

struct itimerspec {
  struct timespec it_interval;
  struct timespec it_value;
};


typedef long daddr_t;
typedef char * caddr_t;
# 166 "/usr/include/sys/types.h" 3
typedef int pid_t;



typedef _ssize_t ssize_t;
# 189 "/usr/include/sys/types.h" 3
typedef unsigned short nlink_t;
# 211 "/usr/include/sys/types.h" 3
typedef long fd_mask;







typedef struct _types_fd_set {
        fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask)
* 8)))];
} _types_fd_set;
# 247 "/usr/include/sys/types.h" 3
typedef unsigned long clockid_t;




typedef unsigned long timer_t;




typedef long useconds_t;


# 1 "/usr/include/sys/features.h" 1 3
# 261 "/usr/include/sys/types.h" 2 3
# 365 "/usr/include/sys/types.h" 3
# 1 "/usr/include/cygwin/types.h" 1 3
# 20 "/usr/include/cygwin/types.h" 3
# 1 "/usr/include/sys/sysmacros.h" 1 3
# 21 "/usr/include/cygwin/types.h" 2 3
# 1 "/usr/include/stdint.h" 1 3
# 18 "/usr/include/stdint.h" 3
typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef long long int64_t;


typedef unsigned char uint8_t;
typedef unsigned short uint16_t;


typedef unsigned long uint32_t;

typedef unsigned long long uint64_t;



typedef signed char int_least8_t;
typedef short int_least16_t;
typedef long int_least32_t;
typedef long long int_least64_t;

typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned long uint_least32_t;
typedef unsigned long long uint_least64_t;



typedef signed char int_fast8_t;
typedef long int_fast16_t;
typedef long int_fast32_t;
typedef long long int_fast64_t;

typedef unsigned char uint_fast8_t;
typedef unsigned long uint_fast16_t;
typedef unsigned long uint_fast32_t;
typedef unsigned long long uint_fast64_t;





typedef long intptr_t;

typedef unsigned long uintptr_t;



typedef long long intmax_t;
typedef unsigned long long uintmax_t;
# 22 "/usr/include/cygwin/types.h" 2 3



typedef struct timespec timespec_t;




typedef struct timespec timestruc_t;





typedef _off64_t off_t;







typedef short __dev16_t;
typedef unsigned long __dev32_t;

typedef __dev32_t dev_t;







typedef long blksize_t;




typedef long __blkcnt32_t;
typedef long long __blkcnt64_t;

typedef __blkcnt64_t blkcnt_t;







typedef unsigned short __uid16_t;
typedef unsigned long __uid32_t;

typedef __uid32_t uid_t;







typedef unsigned short __gid16_t;
typedef unsigned long __gid32_t;

typedef __gid32_t gid_t;







typedef unsigned long __ino32_t;
typedef unsigned long long __ino64_t;

typedef __ino64_t ino_t;







typedef long long key_t;







typedef unsigned long vm_offset_t;




typedef unsigned long vm_size_t;




typedef unsigned char u_int8_t;



typedef __uint16_t u_int16_t;



typedef __uint32_t u_int32_t;



typedef __uint64_t u_int64_t;




typedef __int32_t register_t;




typedef char *addr_t;




typedef unsigned mode_t;





typedef struct __pthread_t {char __dummy;} *pthread_t;
typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;

typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;


typedef struct
{
  pthread_mutex_t mutex;
  int state;
}
pthread_once_t;
typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
# 366 "/usr/include/sys/types.h" 2 3
# 47 "/usr/include/stdio.h" 2 3



typedef __FILE FILE;



typedef _fpos64_t fpos_t;
# 65 "/usr/include/stdio.h" 3
# 1 "/usr/include/sys/stdio.h" 1 3
# 66 "/usr/include/stdio.h" 2 3
# 170 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) tmpfile (void);
char * __attribute__((__cdecl__)) tmpnam (char *);
int __attribute__((__cdecl__)) fclose (FILE *);
int __attribute__((__cdecl__)) fflush (FILE *);
FILE * __attribute__((__cdecl__)) freopen (const char *, const char *, FILE *);
void __attribute__((__cdecl__)) setbuf (FILE *, char *);
int __attribute__((__cdecl__)) setvbuf (FILE *, char *, int, size_t);
int __attribute__((__cdecl__)) fprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) fscanf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) printf (const char *, ...);
int __attribute__((__cdecl__)) scanf (const char *, ...);
int __attribute__((__cdecl__)) sscanf (const char *, const char *, ...);
int __attribute__((__cdecl__)) vfprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vprintf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsprintf (char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) fgetc (FILE *);
char * __attribute__((__cdecl__)) fgets (char *, int, FILE *);
int __attribute__((__cdecl__)) fputc (int, FILE *);
int __attribute__((__cdecl__)) fputs (const char *, FILE *);
int __attribute__((__cdecl__)) getc (FILE *);
int __attribute__((__cdecl__)) getchar (void);
char * __attribute__((__cdecl__)) gets (char *);
int __attribute__((__cdecl__)) putc (int, FILE *);
int __attribute__((__cdecl__)) putchar (int);
int __attribute__((__cdecl__)) puts (const char *);
int __attribute__((__cdecl__)) ungetc (int, FILE *);
size_t __attribute__((__cdecl__)) fread (void *, size_t _size, size_t _n, FILE *);
size_t __attribute__((__cdecl__)) fwrite (const void * , size_t _size, size_t
_n, FILE *);



int __attribute__((__cdecl__)) fgetpos (FILE *, fpos_t *);

int __attribute__((__cdecl__)) fseek (FILE *, long, int);



int __attribute__((__cdecl__)) fsetpos (FILE *, const fpos_t *);

long __attribute__((__cdecl__)) ftell ( FILE *);
void __attribute__((__cdecl__)) rewind (FILE *);
void __attribute__((__cdecl__)) clearerr (FILE *);
int __attribute__((__cdecl__)) feof (FILE *);
int __attribute__((__cdecl__)) ferror (FILE *);
void __attribute__((__cdecl__)) perror (const char *);

FILE * __attribute__((__cdecl__)) fopen (const char *_name, const char *_type);
int __attribute__((__cdecl__)) sprintf (char *, const char *, ...);
int __attribute__((__cdecl__)) remove (const char *);
int __attribute__((__cdecl__)) rename (const char *, const char *);


int __attribute__((__cdecl__)) asprintf (char **, const char *, ...);




int __attribute__((__cdecl__)) fseeko (FILE *, off_t, int);
off_t __attribute__((__cdecl__)) ftello ( FILE *);

int __attribute__((__cdecl__)) vfiprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) iprintf (const char *, ...);
int __attribute__((__cdecl__)) fiprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) siprintf (char *, const char *, ...);
char * __attribute__((__cdecl__)) tempnam (const char *, const char *);
int __attribute__((__cdecl__)) vasprintf (char **, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsnprintf (char *, size_t, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) vfscanf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vscanf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsscanf (const char *, const char *, __gnuc_va_list);

int __attribute__((__cdecl__)) fcloseall (void);
int __attribute__((__cdecl__)) snprintf (char *, size_t, const char *, ...);
# 252 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) fdopen (int, const char *);

int __attribute__((__cdecl__)) fileno (FILE *);
int __attribute__((__cdecl__)) getw (FILE *);
int __attribute__((__cdecl__)) pclose (FILE *);
FILE * __attribute__((__cdecl__)) popen (const char *, const char *);
int __attribute__((__cdecl__)) putw (int, FILE *);
void __attribute__((__cdecl__)) setbuffer (FILE *, char *, int);
int __attribute__((__cdecl__)) setlinebuf (FILE *);
int __attribute__((__cdecl__)) getc_unlocked (FILE *);
int __attribute__((__cdecl__)) getchar_unlocked (void);
void __attribute__((__cdecl__)) flockfile (FILE *);
int __attribute__((__cdecl__)) ftrylockfile (FILE *);
void __attribute__((__cdecl__)) funlockfile (FILE *);
int __attribute__((__cdecl__)) putc_unlocked (int, FILE *);
int __attribute__((__cdecl__)) putchar_unlocked (int);






int __attribute__((__cdecl__)) _asprintf_r (struct _reent *, char **, const char
*, ...);
int __attribute__((__cdecl__)) _fcloseall_r (struct _reent *);
FILE * __attribute__((__cdecl__)) _fdopen_r (struct _reent *, int, const char *);
FILE * __attribute__((__cdecl__)) _fopen_r (struct _reent *, const char *, const
char *);
int __attribute__((__cdecl__)) _fscanf_r (struct _reent *, FILE *, const char *,
...);
int __attribute__((__cdecl__)) _getchar_r (struct _reent *);
char * __attribute__((__cdecl__)) _gets_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _iprintf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _mkstemp_r (struct _reent *, char *);
char * __attribute__((__cdecl__)) _mktemp_r (struct _reent *, char *);
void __attribute__((__cdecl__)) _perror_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _printf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _putchar_r (struct _reent *, int);
int __attribute__((__cdecl__)) _puts_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _remove_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _rename_r (struct _reent *, const char *_old,
const char *_new);

int __attribute__((__cdecl__)) _scanf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _sprintf_r (struct _reent *, char *, const char
*, ...);
int __attribute__((__cdecl__)) _snprintf_r (struct _reent *, char *, size_t,
const char *, ...);
int __attribute__((__cdecl__)) _sscanf_r (struct _reent *, const char *, const
char *, ...);
char * __attribute__((__cdecl__)) _tempnam_r (struct _reent *, const char *,
const char *);
FILE * __attribute__((__cdecl__)) _tmpfile_r (struct _reent *);
char * __attribute__((__cdecl__)) _tmpnam_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _vasprintf_r (struct _reent *, char **, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfprintf_r (struct _reent *, FILE *, const char
*, __gnuc_va_list);
int __attribute__((__cdecl__)) _vprintf_r (struct _reent *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) _vsprintf_r (struct _reent *, char *, const char
*, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsnprintf_r (struct _reent *, char *, size_t,
const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfscanf_r (struct _reent *, FILE *, const char
*, __gnuc_va_list);
int __attribute__((__cdecl__)) _vscanf_r (struct _reent *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) _vsscanf_r (struct _reent *, const char *, const
char *, __gnuc_va_list);

ssize_t __attribute__((__cdecl__)) __getdelim (char **, size_t *, int, FILE *);
ssize_t __attribute__((__cdecl__)) __getline (char **, size_t *, FILE *);
# 334 "/usr/include/stdio.h" 3
int __attribute__((__cdecl__)) __srget (FILE *);
int __attribute__((__cdecl__)) __swbuf (int, FILE *);






FILE *__attribute__((__cdecl__)) funopen (const void * _cookie, int
(*readfn)(void * _cookie, char *_buf, int _n), int (*writefn)(void * _cookie,
const char *_buf, int _n), fpos_t (*seekfn)(void * _cookie, fpos_t _off, int
_whence), int (*closefn)(void * _cookie));
# 359 "/usr/include/stdio.h" 3
static __inline__ int __sgetc(FILE *__p)
  {
    int __c = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
    if ((__p->_flags & 0x4000) && (__c == '\r'))
      {
      int __c2 = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
      if (__c2 == '\n')
        __c = __c2;
      else
        ungetc(__c2, __p);
      }
    return __c;
  }
# 441 "/usr/include/stdio.h" 3
# 185 "gnu-bug.c" 2
# 1 "/usr/include/stdlib.h" 1 3
# 14 "/usr/include/stdlib.h" 3
# 1 "/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 15 "/usr/include/stdlib.h" 2 3


# 1 "/usr/include/machine/stdlib.h" 1 3
# 18 "/usr/include/stdlib.h" 2 3

# 1 "/usr/include/alloca.h" 1 3
# 20 "/usr/include/stdlib.h" 2 3




typedef struct
{
  int quot;
  int rem;
} div_t;

typedef struct
{
  long quot;
  long rem;
} ldiv_t;
# 45 "/usr/include/stdlib.h" 3
extern __attribute__((dllimport)) int __mb_cur_max;



void __attribute__((__cdecl__)) abort (void) __attribute__ ((noreturn));
int __attribute__((__cdecl__)) abs (int);
int __attribute__((__cdecl__)) atexit (void (*__func)(void));
double __attribute__((__cdecl__)) atof (const char *__nptr);

float __attribute__((__cdecl__)) atoff (const char *__nptr);

int __attribute__((__cdecl__)) atoi (const char *__nptr);
long __attribute__((__cdecl__)) atol (const char *__nptr);
void * __attribute__((__cdecl__)) bsearch (const void * __key, const void *
__base, size_t __nmemb, size_t __size, int (* __attribute__((__cdecl__))
_compar) (const void *, const void *));




void * __attribute__((__cdecl__)) calloc (size_t __nmemb, size_t __size);
div_t __attribute__((__cdecl__)) div (int __numer, int __denom);
void __attribute__((__cdecl__)) exit (int __status) __attribute__ ((noreturn));
void __attribute__((__cdecl__)) free (void *);
char * __attribute__((__cdecl__)) getenv (const char *__string);
char * __attribute__((__cdecl__)) _getenv_r (struct _reent *, const char *__string);
char * __attribute__((__cdecl__)) _findenv (const char *, int *);
char * __attribute__((__cdecl__)) _findenv_r (struct _reent *, const char *, int *);
long __attribute__((__cdecl__)) labs (long);
ldiv_t __attribute__((__cdecl__)) ldiv (long __numer, long __denom);
void * __attribute__((__cdecl__)) malloc (size_t __size);
int __attribute__((__cdecl__)) mblen (const char *, size_t);
int __attribute__((__cdecl__)) _mblen_r (struct _reent *, const char *, size_t,
_mbstate_t *);
int __attribute__((__cdecl__)) mbtowc (wchar_t *, const char *, size_t);
int __attribute__((__cdecl__)) _mbtowc_r (struct _reent *, wchar_t *, const char
*, size_t, _mbstate_t *);
int __attribute__((__cdecl__)) wctomb (char *, wchar_t);
int __attribute__((__cdecl__)) _wctomb_r (struct _reent *, char *, wchar_t,
_mbstate_t *);
size_t __attribute__((__cdecl__)) mbstowcs (wchar_t *, const char *, size_t);
size_t __attribute__((__cdecl__)) _mbstowcs_r (struct _reent *, wchar_t *, const
char *, size_t, _mbstate_t *);
size_t __attribute__((__cdecl__)) wcstombs (char *, const wchar_t *, size_t);
size_t __attribute__((__cdecl__)) _wcstombs_r (struct _reent *, char *, const
wchar_t *, size_t, _mbstate_t *);


int __attribute__((__cdecl__)) mkstemp (char *);
char * __attribute__((__cdecl__)) mktemp (char *);


void __attribute__((__cdecl__)) qsort (void * __base, size_t __nmemb, size_t
__size, int(*_compar)(const void *, const void *));
int __attribute__((__cdecl__)) rand (void);
void * __attribute__((__cdecl__)) realloc (void * __r, size_t __size);
void __attribute__((__cdecl__)) srand (unsigned __seed);
double __attribute__((__cdecl__)) strtod (const char *__n, char **__end_PTR);
double __attribute__((__cdecl__)) _strtod_r (struct _reent *,const char *__n,
char **__end_PTR);
float __attribute__((__cdecl__)) strtof (const char *__n, char **__end_PTR);






long __attribute__((__cdecl__)) strtol (const char *__n, char **__end_PTR, int
__base);
long __attribute__((__cdecl__)) _strtol_r (struct _reent *,const char *__n, char
**__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) strtoul (const char *__n, char
**__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) _strtoul_r (struct _reent *,const char
*__n, char **__end_PTR, int __base);

int __attribute__((__cdecl__)) system (const char *__string);


long __attribute__((__cdecl__)) a64l (const char *__input);
char * __attribute__((__cdecl__)) l64a (long __input);
char * __attribute__((__cdecl__)) _l64a_r (struct _reent *,long __input);
int __attribute__((__cdecl__)) on_exit (void (*__func)(int, void *),void * __arg);
void __attribute__((__cdecl__)) _Exit (int __status) __attribute__ ((noreturn));
int __attribute__((__cdecl__)) putenv (const char *__string);
int __attribute__((__cdecl__)) _putenv_r (struct _reent *, const char *__string);
int __attribute__((__cdecl__)) setenv (const char *__string, const char
*__value, int __overwrite);
int __attribute__((__cdecl__)) _setenv_r (struct _reent *, const char *__string,
const char *__value, int __overwrite);

char * __attribute__((__cdecl__)) gcvt (double,int,char *);
char * __attribute__((__cdecl__)) gcvtf (float,int,char *);
char * __attribute__((__cdecl__)) fcvt (double,int,int *,int *);
char * __attribute__((__cdecl__)) fcvtf (float,int,int *,int *);
char * __attribute__((__cdecl__)) ecvt (double,int,int *,int *);
char * __attribute__((__cdecl__)) ecvtbuf (double, int, int*, int*, char *);
char * __attribute__((__cdecl__)) fcvtbuf (double, int, int*, int*, char *);
char * __attribute__((__cdecl__)) ecvtf (float,int,int *,int *);
char * __attribute__((__cdecl__)) dtoa (double, int, int, int *, int*, char**);
int __attribute__((__cdecl__)) rand_r (unsigned *__seed);

double __attribute__((__cdecl__)) drand48 (void);
double __attribute__((__cdecl__)) _drand48_r (struct _reent *);
double __attribute__((__cdecl__)) erand48 (unsigned short [3]);
double __attribute__((__cdecl__)) _erand48_r (struct _reent *, unsigned short [3]);
long __attribute__((__cdecl__)) jrand48 (unsigned short [3]);
long __attribute__((__cdecl__)) _jrand48_r (struct _reent *, unsigned short [3]);
void __attribute__((__cdecl__)) lcong48 (unsigned short [7]);
void __attribute__((__cdecl__)) _lcong48_r (struct _reent *, unsigned short [7]);
long __attribute__((__cdecl__)) lrand48 (void);
long __attribute__((__cdecl__)) _lrand48_r (struct _reent *);
long __attribute__((__cdecl__)) mrand48 (void);
long __attribute__((__cdecl__)) _mrand48_r (struct _reent *);
long __attribute__((__cdecl__)) nrand48 (unsigned short [3]);
long __attribute__((__cdecl__)) _nrand48_r (struct _reent *, unsigned short [3]);
unsigned short *
       __attribute__((__cdecl__)) seed48 (unsigned short [3]);
unsigned short *
       __attribute__((__cdecl__)) _seed48_r (struct _reent *, unsigned short [3]);
void __attribute__((__cdecl__)) srand48 (long);
void __attribute__((__cdecl__)) _srand48_r (struct _reent *, long);
long long __attribute__((__cdecl__)) strtoll (const char *__n, char **__end_PTR,
int __base);
long long __attribute__((__cdecl__)) _strtoll_r (struct _reent *, const char
*__n, char **__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) strtoull (const char *__n, char
**__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) _strtoull_r (struct _reent *,
const char *__n, char **__end_PTR, int __base);




char * __attribute__((__cdecl__)) realpath (const char *, char *);
void __attribute__((__cdecl__)) unsetenv (const char *__string);
void __attribute__((__cdecl__)) _unsetenv_r (struct _reent *, const char *__string);
int __attribute__((__cdecl__)) random (void);
long __attribute__((__cdecl__)) srandom (unsigned __seed);
char * __attribute__((__cdecl__)) ptsname (int);
int __attribute__((__cdecl__)) grantpt (int);
int __attribute__((__cdecl__)) unlockpt (int);




char * __attribute__((__cdecl__)) _dtoa_r (struct _reent *, double, int, int,
int *, int*, char**);







int __attribute__((__cdecl__)) _system_r (struct _reent *, const char *);

void __attribute__((__cdecl__)) __eprintf (const char *, const char *, unsigned
int, const char *);
# 213 "/usr/include/stdlib.h" 3
# 186 "gnu-bug.c" 2





typedef unsigned char byte8 __attribute__((aligned(1)));
typedef unsigned short word16 __attribute__((aligned(1)));
typedef struct { byte8 b[3]; } word24 __attribute__((aligned(1)));
typedef unsigned long word32 __attribute__((aligned(1)));
# 226 "gnu-bug.c"
char *dir_strs[] = { "Recv", "Send" };





unsigned int lineno = 0;
# 241 "gnu-bug.c"
typedef struct tblmem_s
{
                struct tblmem_s *tbl_next;
                word16 tbl_id;
                word16 tbl_len;
                word16 tbl_size;
                byte8 * tbl_data;
} tblmem_t;

extern tblmem_t *lookup_table (word16 tableid, word16 size);

typedef struct table_s
{
                word16 tbl_count;
                byte8 tbl_data[0 ];
                byte8 tbl_cksum;

} table_t;





typedef unsigned char BOOL __attribute__((aligned(1)));
typedef unsigned char CHAR __attribute__((aligned(1)));
typedef unsigned int FILL __attribute__((aligned(1)));
typedef signed int INT __attribute__((aligned(1)));
typedef signed char INT8 __attribute__((aligned(1)));
typedef signed short INT16 __attribute__((aligned(1)));
typedef signed long INT32 __attribute__((aligned(1)));
typedef unsigned int UINT __attribute__((aligned(1)));
typedef unsigned char UINT8 __attribute__((aligned(1)));
typedef unsigned short UINT16 __attribute__((aligned(1)));
typedef struct { UINT16 l; UINT8 h; } UINT24 __attribute__((aligned(1)));
typedef unsigned long UINT32 __attribute__((aligned(1)));
typedef struct { UINT32 lo; INT16 hi; } INT48 __attribute__((aligned(1)));
typedef signed long long INT64 __attribute__((aligned(1)));
typedef unsigned long long UINT64 __attribute__((aligned(1)));





typedef INT48 NI_FMAT1 __attribute__((aligned(1)));
typedef INT32 NI_FMAT2 __attribute__((aligned(1)));

typedef struct
{
                UINT8 sd_year;
                UINT8 sd_month;
                UINT8 sd_day;
                UINT8 sd_hour;
                UINT8 sd_minute;

} STIME_DATE;




typedef struct tbl_s21_s
{
                BOOL s21_season_info_field : 1;
                BOOL s21_date_time_field : 1;
                BOOL s21_demand_reset_ctr : 1;
                BOOL s21_demand_reset_lock : 1;
                BOOL s21_cum_demand : 1;
                BOOL s21_cont_cum_demand : 1;
                BOOL s21_time_remaining : 1;
                FILL : 1;

                BOOL s21_self_read_inh_ovf : 1;
                BOOL s21_self_read_seq_nbr : 1;
                BOOL s21_daily_self_read : 1;
                BOOL s21_weekly_self_read : 1;
                UINT s21_read_demand_reset : 2;
                FILL : 2;

                UINT8 s21_nbr_self_reads;
                UINT8 s21_nbr_summations;
                UINT8 s21_nbr_demands;
                UINT8 s21_nbr_coin_values;
                UINT8 s21_nbr_occur;
                UINT8 s21_nbr_tiers;
                UINT8 s21_nbr_present_demands;
                UINT8 s21_nbr_present_values;

} tbl_s21_t;

void
decode_s21 (word16 tid, tblmem_t *tbl)
{
    tbl_s21_t *s21 = (tbl_s21_t *) tbl->tbl_data;

    if (tbl->tbl_len < sizeof(tbl_s21_t))
        return;
    printf("TBL  s21:");
    if (tbl->tbl_len != sizeof(tbl_s21_t))
    {
        printf(" !badlen!\n");
        fprintf(((__getreent())->_stderr), "!! TBL s21 incorrect length %u
expected %u"
                " around line %u\n",
                tbl->tbl_len,
                sizeof(tbl_s21_t),
                lineno);
        return;
    }
    else
        printf("\n");

    printf("TBL  s%u %-21s= %s\n", tid, "season_info_field",
s21->s21_season_info_field ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "date_time_field",
s21->s21_date_time_field ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "demand_reset_ctr",
s21->s21_demand_reset_ctr ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "demand_reset_lock",
s21->s21_demand_reset_lock ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "cum_demand", s21->s21_cum_demand ?
"TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "cont_cum_demand",
s21->s21_cont_cum_demand ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "time_remaining",
s21->s21_time_remaining ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "self_read_inh_ovf",
s21->s21_self_read_inh_ovf ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "self_read_seq_nbr",
s21->s21_self_read_seq_nbr ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "daily_self_read",
s21->s21_daily_self_read ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %s\n", tid, "weekly_self_read",
s21->s21_weekly_self_read ? "TRUE" : "FALSE");
    printf("TBL  s%u %-21s= %u\n", tid, "read_demand_reset",
s21->s21_read_demand_reset);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_self_reads", s21->s21_nbr_self_reads);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_summations", s21->s21_nbr_summations);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_demands", s21->s21_nbr_demands);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_coin_values",
s21->s21_nbr_coin_values);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_occur", s21->s21_nbr_occur);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_tiers", s21->s21_nbr_tiers);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_present_demands",
s21->s21_nbr_present_demands);
    printf("TBL  s%u %-21s= %u\n", tid, "nbr_present_values",
s21->s21_nbr_present_values);
}
# 380 "gnu-bug.c"
int
decode_s23 (word16 tid, tblmem_t *tbl, tbl_s21_t *s21)
{
  typedef struct demands_s
  {
                STIME_DATE dem_event_time[s21->s21_date_time_field *
                                               s21->s21_nbr_occur];
                NI_FMAT1 dem_cum_demand[s21->s21_cum_demand];
                NI_FMAT1 dem_cont_cum_demand[s21->s21_cont_cum_demand];
                NI_FMAT2 dem_demand[s21->s21_nbr_occur];

  } demands_t;

  typedef struct data_blk_s
  {
                NI_FMAT1 db_summations [s21->s21_nbr_summations];
                demands_t db_demands [s21->s21_nbr_demands];
                NI_FMAT2 db_coincidents[s21->s21_nbr_coin_values]
                                              [s21->s21_nbr_occur];

  } data_blk_t;

  typedef struct tbl_s23_s
  {
                UINT8 s23_nbr_demand_resets;
                data_blk_t s23_tot_data_block;
                data_blk_t s23_tier_data_block[s21->s21_nbr_tiers];
  } tbl_s23_t;

  void
  print_data_blk (word16 tid, data_blk_t *db, tbl_s21_t *s21)
  {
    int i, o;


    for (i = 0; i < s21->s21_nbr_summations; i++)
    {
        printf("TBL  s21   summations[%u]      = %lld\n",
                i,
                ((((INT64) ((db->db_summations[i]).hi)) << 32) | ((UINT64)
((db->db_summations[i]).lo))));
    }


    for (i = 0; i < s21->s21_nbr_demands; i++)
    {
        demands_t *dem = &db->db_demands[i];

        if (s21->s21_cum_demand)
            printf("TBL  s21   demands[%u].cum     = %lld\n",
                    i,
                    ((((INT64) ((dem->dem_cum_demand[0]).hi)) << 32) | ((UINT64)
((dem->dem_cum_demand[0]).lo))));
        if (s21->s21_cont_cum_demand)
            printf("TBL  s21   demands[%u].cum     = %lld\n",
                    i,
                    ((((INT64) ((dem->dem_cont_cum_demand[0]).hi)) << 32) |
((UINT64) ((dem->dem_cont_cum_demand[0]).lo))));
        for (o = 0; o < s21->s21_nbr_occur; o++)
            printf("TBL  s21   demands[%u][%3u]    = %-10ld\n",
                    i, o,
                    dem->dem_demand[o]);
    }


    for (i = 0; i < s21->s21_nbr_coin_values; i++)
    {
        for (o = 0; o < s21->s21_nbr_occur; o++)
        {
            printf("TBL  s21   coincidents[%u][%3u]= %lu\n",
                    i, o,
                    db->db_coincidents[i][o]);
        }
    }

  }

    tbl_s23_t *s23;
    int i;

    switch (tid)
    {
      case 23:
        s23 = (tbl_s23_t *) tbl->tbl_data;
        if (tbl->tbl_len < sizeof(tbl_s23_t))
            return(-1);
        printf("TBL  s23:");
        if (tbl->tbl_len != sizeof(tbl_s23_t))
        {
            printf(" !badlen! %u expected %u\n",
                    tbl->tbl_len, sizeof(tbl_s23_t));
            fprintf(((__getreent())->_stderr), "!! TBL s23 incorrect length %u
expected %u"
                    " around line %u\n",
                    tbl->tbl_len,
                    sizeof(tbl_s23_t),
                    lineno);
            return(-1);
        }
        else
            printf("\n");
        break;

      case 24:
      case 25:
        s23 = (tbl_s23_t *) tbl;
        break;

      default:
        return(sizeof(tbl_s23_t));
    }

    printf("TBL  s%u %-21s= %u\n", tid,
            "nbr_demand_resets",
            s23->s23_nbr_demand_resets);
    if (sizeof(s23->s23_tot_data_block) > 0)
    {
        printf("TBL  s%u %-21s=\n", tid,
                "tot_data_block");
        print_data_blk(tid, &s23->s23_tot_data_block, s21);

    }
    if (sizeof(s23->s23_tier_data_block) > 0)
    {
        for (i = 0; i < s21->s21_nbr_tiers; i++)
        {
            printf("TBL  s%u tier_data_block[%u]   =\n", tid,
                    i);
            print_data_blk(tid, &s23->s23_tier_data_block[i], s21);

        }
    }
}





int
decode_s24 (word16 tid, tblmem_t *tbl, tbl_s21_t *s21)
{
  typedef struct tbl_s24_s
  {
                STIME_DATE s24_end_date_time[s21->s21_date_time_field];
                UINT8 s24_season[s21->s21_season_info_field];
                byte8 s24_prev_season_reg_data[
                                                    decode_s23(0, ((void *)0),
s21)];
  } tbl_s24_t;

  char *tid_strs[] =
  {
                "prev_season_reg_data",
                "prev_demand_reset_data",
                "self_read_register_data",
  };

    tbl_s24_t *s24;

    switch (tid)
    {
      case 24:
      case 25:
        s24 = (tbl_s24_t *) tbl->tbl_data;
        if (tbl->tbl_len < sizeof(tbl_s24_t))
            return(-1);
        printf("TBL  s%u:", tid);
        if (tbl->tbl_len != sizeof(tbl_s24_t))
        {
            printf(" !badlen! %u expected %u\n",
                    tbl->tbl_len, sizeof(tbl_s24_t));
            fprintf(((__getreent())->_stderr), "!! TBL s%u incorrect length %u
expected %u"
                    " around line %u\n",
                    tid,
                    tbl->tbl_len,
                    sizeof(tbl_s24_t),
                    lineno);
            return(-1);
        }
        else
            printf("\n");
        break;

      case 26:
        s24 = (tbl_s24_t *) tbl;
        break;

      default:
        return(sizeof(tbl_s24_t));
    }

    if (s21->s21_season_info_field)
        printf("TBL  s%u %-21s= %u\n", tid,
                "season",
                s24->s24_season[0]);
    printf("TBL  s%u %s:\n", tid,
            tid_strs[tid - 24]);
    (void) decode_s23(tid, (tblmem_t *) s24->s24_prev_season_reg_data, s21);
}






tblmem_t *
lookup_table (word16 tableid, word16 size)
{
    static tblmem_t *tbl_head = ((void *)0);
    tblmem_t *tbl;

    for (tbl = tbl_head; tbl != ((void *)0); tbl = tbl->tbl_next)
    {
        if (tbl->tbl_id == tableid)
        {
            if ((size > 0) && (size > tbl->tbl_size))
            {
                byte8 *new_data = (byte8 *) realloc(tbl->tbl_data, size);

                if (new_data == ((void *)0))
                {
                    fprintf(((__getreent())->_stderr), "!! lookup_table()
realloc() failure\n");
                    exit(1);
                }
                memset(&new_data[tbl->tbl_size], 0, size - tbl->tbl_size);
                tbl->tbl_data = new_data;
                tbl->tbl_size = size;
            }
            return(tbl);
        }
    }

    if (size == 0)
        return(((void *)0));

    tbl = malloc(sizeof(tblmem_t));
    if (tbl == ((void *)0))
    {
        fprintf(((__getreent())->_stderr), "!! lookup_table() malloc() failure\n");
        exit(1);
    }
    tbl->tbl_id = tableid;
    tbl->tbl_len = 0;
    tbl->tbl_size = size;
    tbl->tbl_data = calloc(size, 1);
    if (tbl->tbl_data == ((void *)0))
    {
        fprintf(((__getreent())->_stderr), "!! lookup_table() calloc() failure\n");
        exit(1);
    }

    tbl->tbl_next = tbl_head;
    tbl_head = tbl;
    return(tbl);
}


int
decode_table (word16 tableid, byte8 *data, word16 len, word16 offset)
{
    tblmem_t *tbl;


    tbl = lookup_table(tableid, offset + len);
    if (tbl == ((void *)0))
    {
        fprintf(((__getreent())->_stderr), "!! decode_table() lookup failed\n");
        return(-1);
    }

    memcpy(&tbl->tbl_data[offset], data, len);
    tbl->tbl_len = offset + len;


    switch (tableid)
    {
      case 21:
        decode_s21(tableid, tbl);
        break;


      case 23:
      {
        tblmem_t *tbl21 = lookup_table(21, 0);

        if ((tbl21 == ((void *)0)) || (tbl21->tbl_len < sizeof(tbl_s21_t)))
            break;
        decode_s23(tableid, tbl, (tbl_s21_t *) tbl21->tbl_data);
        break;
      }

      case 24:
      case 25:
      {
        tblmem_t *tbl21 = lookup_table(21, 0);

        if ((tbl21 == ((void *)0)) || (tbl21->tbl_len < sizeof(tbl_s21_t)))
            break;
        (void) decode_s24(tableid, tbl, (tbl_s21_t *) tbl21->tbl_data);
        break;
      }

      default:
        break;
    }
}

byte8 s21_data[10] = { 0x5F, 0x10, 0x0C, 0x05, 0x05, 0x0A, 0x01, 0x04,
                        0x00, 0x00,
};

byte8 s24_data[732] = { 0x04, 0x01, 0x05, 0x0A, 0x2E, 0x45,
};

int
main ()
{
    decode_table (21, s21_data, sizeof(s21_data), 0);
    s24_data[sizeof(s24_data)-1] = 0xFF;

    decode_table (24, s24_data, sizeof(s24_data), 0);

    exit(0);
}
----------

-- 
           Summary: Variable-length arrays broke in gcc 3.x?
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dmarkuson at arrayinc dot com
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list