home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!uwm.edu!rutgers!psinntp!psinntp!rsi!prcrs!paul
- From: paul@prcrs.prc.com (Paul Hite)
- Newsgroups: comp.sys.hp
- Subject: Re: that HPUX cc compiler
- Message-ID: <4722@prcrs.prc.com>
- Date: 2 Sep 92 15:14:42 GMT
- References: <1992Aug31.104950.1108@bohra.cpg.oz.au>
- Organization: PRC Realty Systems, McLean, VA
- Lines: 49
-
-
- HP gets a lot of grief from the behavior of their c optimizer. I'm sure
- that some of it is valid. But a lot of the posts basicly say something
- like:
- I've got a program that works without the optimizer and fails
- when I optimize it. Therefore HP's optimizer is broken.
-
- Here's a real live counter-example to that argument. I wrote a replacement
- to w and it worked without the optimizer and failed when I optimized it.
- I reduced the program to a tiny example that also failed with the optimizer.
- The complete program is below my signature, but here is the important part:
- struct utmp entry;
- while(fread(entry, sizeof entry, 1, u)) {
- bogus = entry.ut_time;
- With the optimizer, bogus always had the same value. Without the optimizer
- various correct values are printed. The problem is the fread. It should be:
- while(fread(&entry, sizeof entry, 1, u)) {
- ^
- And the optimizer works fine on the corrected program. Actually it's amazing
- that the program works at all the first way. All of this is on an 847, those
- of you on other platforms may get different results with the buggy program.
- (Indeed, Steinar Haug found the bug for me as he struggled to get my program
- working on a 425!)
-
- But my point is that the existence of a program like mine that fails when
- optimized does not necessarily prove that the optimizer is broken. It may
- be that the program is broken.
-
- Paul Hite PRC Realty Systems McLean,Va paul@prcrs.prc.com (703) 556-2243
- "We are trying to bring up an Air Traffic Control display on an X window
- terminal and there seems to be some problems." -- from comp.windows.x
- --------------
- #include <stdio.h>
- #include <sys/stat.h>
- #include <utmp.h>
- #include <time.h>
- time_t bogus;
- main ()
- {
- FILE *u;
- struct utmp entry;
- u = fopen("/etc/utmp","r");
- while(fread(entry, sizeof entry, 1, u)) {
- bogus = entry.ut_time;
- printf("bogus = %d\n");
- }
- fclose(u);
- exit(0);
- }
-