www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/05/02/13:27:33

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU
Date: Tue, 2 May 1995 08:21:51 BST
Subject: Bad bug with for(-;-;-) and an enum name

  I am writing to report a bad bug that has just caused me 2 days' wasted work
in translating an X-ray crystallography program from old-style mainframe
Fortran into interactive PC for someone in another department.
  I am currently using this version of djgpp:-
DJ112M1.ZIP     DJ112M2.ZIP     DJDEV112.ZIP    DJDOC112.ZIP    DJEMU112.ZIP
DJEOE112.ZIP    DJLGR112.ZIP    DJLSR112.ZIP    DJSRC112.ZIP    DJTST112.ZIP
FSDB091A.ZIP    GAS23BN.ZIP     GAS23DC.ZIP     GCC260BN.ZIP    GCC260DC.ZIP
GCC260RM.ZIP    GDB412BN.ZIP    GDB412DC.ZIP    GPP260.ZIP      LGP260BN.ZIP
LGP260DC.ZIP    LGP260SR.ZIP    TXI310BN.ZIP    TXI310DC.ZIP    WMEMU112.ZIP
  (I had to change back from a later version of djgpp because of another bug
which I will describe separately later.)

#include<stdio.h>
enum{q=1,imax=256};
main(){double x,y; int i,j,k,l,im=imax;
printf("A: "); for(i=-im  ;i<im  ;i++) printf("%d ",i); printf("\n");
printf("B: "); for(i=-imax;i<imax;i++) printf("%d ",i); printf("\n");}

  When this Gnu C++ program runs, loop A prints consecutive numbers on screen
as expected, but loop B prints <<no numbers at all>>.

#include<stdio.h>
enum{q=1,imax=256};
main(){double x,y; int i,j,k,l,im=imax;
printf("A: "); for(i=-im  ;i<=im  ;i++) printf("%d ",i); printf("\n");
printf("B: "); for(i=-imax;;i++) {printf("%d ",i); break;} printf("\n");}

  But in this slightly different Gnu C++ program both loops run as expected.
  (I was also getting that bug with the later version of djgpp that I was
using.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019