Potize s funkci gethostbyname v C

Derfinak Jan derfinak na hron.fei.tuke.sk
Středa Duben 22 17:43:02 CEST 1998


On Tue, 21 Apr 1998, Martin Mares wrote:

> Hi,
> 
> > Pokud vim, gcc 2.7.2.1 ma nejakou chybu tykajici se deleni nulou (uz si to
> > presne nepamatuju) a projevovala se pri kompilaci ssh. Pomohl upgrade na
> > 2.7.2.3.
> 
>    Tyka se pouze verze 2.7.2.1-f1 (ta, co vznikne pri staveni GCC baliku
> s kompilatorem Fortranu).

Aj tak by som odporucil upgrade. Toto platilo este aj na 2.7.2.2:

/* This file exhibits an optimizer bug of gcc-2.7.2.2 on
   Linux. Compile with "gcc -O -funroll-loops -o bug bug.c". It
   computes twice the same short table, and should get the same
   results.  Compiling with "-O" or with "-funroll-loops" alone does
   not cause the bug to show.
   23 JUN 1997
   Uwe F. Mayer <mayer na math.vanderbilt.edu> */

#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif

#define TRUE (0==0)
#define FALSE (1==0)

int main (){
  int i,f,n=9;
  int table0[50][3];
  int table1[50][3];
  int same=TRUE;

  /* this is the correct table */
  table0[0][0]=9 ; table0[0][1]=10; table0[0][2]=36;
  table0[1][0]=10; table0[1][1]=37; table0[1][2]=36;
  table0[2][0]=10; table0[2][1]=11; table0[2][2]=37;
  table0[3][0]=11; table0[3][1]=38; table0[3][2]=37;
  table0[4][0]=11; table0[4][1]=12; table0[4][2]=38;
  table0[5][0]=12; table0[5][1]=39; table0[5][2]=38;
  table0[6][0]=12; table0[6][1]=13; table0[6][2]=39;
  table0[7][0]=13; table0[7][1]=40; table0[7][2]=39;
  table0[8][0]=13; table0[8][1]=14; table0[8][2]=40;
  table0[9][0]=14; table0[9][1]=41; table0[9][2]=40;
  table0[10][0]=14; table0[10][1]=15; table0[10][2]=41;
  table0[11][0]=15; table0[11][1]=42; table0[11][2]=41;
  table0[12][0]=15; table0[12][1]=16; table0[12][2]=42;
  table0[13][0]=16; table0[13][1]=43; table0[13][2]=42;
  table0[14][0]=16; table0[14][1]=17; table0[14][2]=43;
  table0[15][0]=17; table0[15][1]=44; table0[15][2]=43;

  /* This loop should exhibit the bug. */
  f=0;
  for(i=0;i<n-1;i++){
    table1[f][0]=n+i;
    table1[f][1]=n+i+1;
    table1[f++][2]=i+4*n;
    table1[f][0]=n+i+1;
    table1[f][1]=i+4*n+1;
    table1[f++][2]=i+4*n;
  }

  /* Now compare the two tables */
  for(i=0;i<2*(n-1);i++){
    same=same && (table0[i][0]==table1[i][0]);
    same=same && (table0[i][1]==table1[i][1]);
    same=same && (table0[i][2]==table1[i][2]);
  }

  printf("\nCORRECT    | BUGGY ??\n");
  printf("-----------+-------------\n");
  for(i=0;i<f;i++){
    printf("%3d%3d%3d  |  %3d%3d%3d\n",
	   table0[i][0],table0[i][1],table0[i][2],
	   table1[i][0],table1[i][1],table1[i][2]);
  }

  if (same) {
    printf("\nThe two tables are the same.\n\n");
  } else {
    printf("\nThe two tables are NOT the same.\n\n");
  }

  return(0);  
}


----- I can't get no satisfaction -----
			Rolling Stones
 



Další informace o konferenci Linux