From: gunnar@Mathematik.Uni-Bielefeld.DE (Gunnar Brinkmann)
Subject: Compiler ERROR
Date: 1995/08/17 [thread overview]
Message-ID: <DDGHsA.CFz@hermes.hrz.uni-bielefeld.de> (raw)
The following program is a stripped part of a larger program, where an error
occured when it was compiled with cc -O3 (only with -O3). The error can easily
be seen in the for( ... i<=vnumber...) where we have i>vnumber in the loop.
It is marked
/*****************LOOP WHERE THE PROBLEM OCCURS*************************/
The program (also the large original one) works OK with O2 or being compiled by
gcc and any optimization. I hope someone responsible for fixing such bugs reads
this and can detect the problem. It is one that MUST have occured at least
1000 times before ...
I am talking about the standard compiler of OSF1 V3.0.
Gunnar Brinkmann
#include<stdio.h>
#define leer 0
#define nil 0
#define knoten 55 /* immer gross genug fuer den kantendualen graphen !!!! */
#define MAXVAL 12
#define MAXSPACE 8000000 /* Wieviel Bytes darf er maximal allocieren */
typedef unsigned char GRAPH[knoten+1][MAXVAL];
int vnumber;
/*************************BELEGEMARKS********************************/
void belegemarks(int start,GRAPH gr,char *marks)
{
int i;
for (i=0; gr[start][i] != leer; i++)
if (!marks[gr[start][i]])
{ marks[gr[start][i]]=1;
belegemarks(gr[start][i],gr,marks); }
}
/**************************COMPONENTS*********************************/
int components(GRAPH gr)
/* Ueberprueft die Anzahl der Komponenten von graph -- dabei ist nur wichtig, ob 1
oder mehr als 1 -- Gibt 1 oder 2 zurueck -- 2 auch, wenn 3 oder mehr komponenten
da sind */
{
int i,j;
char marks[knoten+1];
for (i=1; i<=vnumber; i++) marks[i]=0;
for (i=1; gr[i][0]==leer; i++);
belegemarks(i,gr,marks);/* If this is deleted, the following loop works correctly*/
/*****************LOOP WHERE THE PROBLEM OCCURS*************************/
/* works also with + 0,1,2,... in the if statement -- not with an additional
fprintf without exit */
for (i=1; i<=vnumber; i++) {
if ( (i+14) > (2*vnumber)+10)
{fprintf(stderr,"i: %d vnumber: %d\n",i,vnumber); exit(0);}
} /* if the exit is deleted, the loop works OK. with a return, the error also
occurs */
return(1);
}
/******************************MAIN************************************/
main(argc,argv)
int argc;
char *argv[];
{
GRAPH gr;
int i,j;
for (i=1; i<=knoten+1; i++) for (j=0; j<MAXVAL; j++) gr[i][j]=leer;
for (i=1; i<=14; i++) { gr[i][0]= i-1; gr[i][1]=i+1; } gr[1][0]=14; gr[14][1]=1;
vnumber=14;
components(gr);
return(0);
}
reply other threads:[~1995-08-17 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox