From: Simon Wistow Date: 11:38 on 05 Apr 2004 Subject: "hating gcc" or "random errors make life interesting" I am starting to get used to the fact that some specialist software, which doesn't have the benefit of a massive testing base, doesn't do what it says on the tin. The most recent one being some SAN software that, despite its only real job being to hold a sequences of bits in *precisely* the same order was when they were put down, err, doesn't. Random flip-flop a-go-go. *sigh* But that is a diffwerent hate. And at leats the developers are responsive. However gcc has *masses* of testing. Masses. It is, probbaly, the most widely used compiler in the world or, if not, close. [0] I have this code. It is fairly crufty because I've spent the last two working days (well, 1 and a half including this morning) rewriting it and rewriting it and cursing myself for inexplicably having a 2 day braino. Yes. I blamed myself. As Klortho's advice number 11907 says -*- Looking for a compiler bug is the strategy of LAST resort. LAST resort. -*- And this was a potential mass of fence post erros and a whole other county things. while (i=files()) { if (_start<0) _start = i; if (_end<0) _end = i; if (_end<i-1 || i<0) { if (_start != _end) { cerr << _start << "-" << _end; } else { cerr << _start; } if (i>=0) { cerr << ", "; } _start = i; } _end = i; if (i<0) break; //cerr << ""; } The code is designed to take a list of numbers such as 1,2,3,4,6,8,9,11 and turn them into 1-4, 6, 8-9, 11 Which is all well and good. Except, well, notice the commented out thing at the bottom? If I uncomment it, it works perfectly. If it's commented than it all goes tits up and never recognises the end of a sub-sequence. *sigh* And turning off O2 optimisation doens't work either. I'm wondering if it's some reserved token problem based on _end. Hrrmm, no. Changing it to _foo doesn't work either. My god, it really is shite. I hate you gcc. May a thosuand hairy backed baboons violate your ocular cavities. Simon [0] Warning, contains traces of arbitary numbers and wild speculation
From: peter (Peter da Silva) Date: 13:54 on 05 Apr 2004 Subject: Re: "hating gcc" or "random errors make life interesting" > if (i<0) break; > //cerr << ""; > Which is all well and good. Except, well, notice the commented out > thing at the bottom? If I uncomment it, it works perfectly. If it's > commented than it all goes tits up and never recognises the end of a > sub-sequence. I have EXACTLY the same problem with a C (not C++) program on HPUX 11 using HP's own compiler (not GCC). This is on code I originally wrote for Xenix-286 in 1980... something that's been ported to SVR0-68000, SVR2-x86, Solaris-Sparc, Solaris-X86, OpenVMS-VAX, OpenVMS-Alpha, SCO, OSF1^WDigital UNIX^W^WTru64, FreeBSD, and Linux. If I put any debugging code, even 'fprintf(stderr, "");', it works, otherwise it terminates (normally, exit(0)) without producing output.
From: Simon Wistow Date: 15:02 on 05 Apr 2004 Subject: Re: "hating gcc" or "random errors make life interesting" On Mon, Apr 05, 2004 at 07:54:23AM -0500, Peter da Silva said: > If I put any debugging code, even 'fprintf(stderr, "");', it works, > otherwise it terminates (normally, exit(0)) without producing output. Curiouser and curiouser it turned out to be an occasionally bogus return from stat which was somehow being flushed by the cerr call. *sigh*
Generated at 10:27 on 16 Apr 2008 by mariachi