[Prev][Next][Index]

Bug with generated print functions in pC++



Dear Sages,

I've run into what looks like a pretty inconvenient bug in the pC++
compiler.  It generates two print functions without parameter type
declarations in the second argument.  As a result, I get incorrect
output unless I edit the temp.C file after each compile to put in the
correct type declarations.  This is a pain; if you know of a
workaround or a bug fix for this please let me know.

Rob Helm

--------------------------------------------------------------------

/*==============================================================*/
/*	Functions affected by bug - source		        */
/* NOTE: FIXED is typedef'd to long int.			*/
/*==============================================================*/



void FixedVector::print() {
  int i;	// Loop index
  FIXED tmp;	// temporary (work around pC++ bug)

  printf("[ ");
  for (i = 0; (i < size); i++) {
    tmp = value[i];
    printf("%ld ", tmp);	/* THIS STATEMENT AFFECTED */
  }
  printf(" ]");
}


void SparseMatrix::print() {
  int i, j;		// Loop indices
  ColumnEntryp p;	// Column entries in m
  FIXED tmp;		// Temporary (work around pC++ bug).

  for (i = 0; (i < rows); i++) {
    p = rowStart[i];
    printf("\n| ");
    for (j = 0; ((j < cols) && (p < rowStart[i+1])); j++) {
      if ((p->col) == j) {
        tmp = p->val;
	printf("%ld", tmp);	/* THIS STATEMENT AFFECTED */
	p++;
      } else {
        printf("..");
      }
      printf(" ");
    }
    printf("| (%d)", i);
  }
}



/*==============================================================*/
/*	Functions affected by bug - temp.C		        */
/*==============================================================*/


void  FixedVector:: print(){
       int i;
       FIXED tmp;
       pcxx_printf43("[ ");
       for (i = 0 ; (i < size) ; (i)++)
       {
          tmp = value[i];
          pcxx_printf44("%ld ", tmp);	/* THIS STATEMENT AFFECTED */
        }
       pcxx_printf45(" ]");
}

void  SparseMatrix:: print(){
       int i, j;
       ColumnEntryp p;
       FIXED tmp;
       for (i = 0 ; (i < rows) ; (i)++)
       {
          p = rowStart[i];
          pcxx_printf46("\n| ");
          for (j = 0 ; ((j < cols) && (p < rowStart[i + 1])) ; (j)++)
          {
             if ((p->col) == j) 
             {
                tmp = p->val;
                pcxx_printf47("%ld", tmp);	/* THIS STATEMENT AFFECTED */
                (p)++;
              }
              else{
                pcxx_printf48("..");
              }
             pcxx_printf49(" ");
           }
          pcxx_printf50("| (%d)", i);
        }
}



/*==============================================================*/
/*	Generated print functions				*/
/*==============================================================*/

int  pcxx_printf44(char *pCar_0,  /* ADD HERE long int */ pCar_1){
       if ((pcxx_NodeNumber() == 0) || pcxx_inpar) 
       {
          printf(pCar_0, pCar_1);
        }
        return 1;
 }

int  pcxx_printf47(char *pCar_0,  /* ADD HERE long int */ pCar_1){
       if ((pcxx_NodeNumber() == 0) || pcxx_inpar) 
       {
          printf(pCar_0, pCar_1);
        }
        return 1;
 }