home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!slhp1.epfl.ch!lecom
- From: lecom@slhp1.epfl.ch (Claude Lecommandeur)
- Newsgroups: comp.sys.hp
- Subject: Re: that HPUX cc compiler
- Message-ID: <3939@sicsun.epfl.ch>
- Date: 4 Sep 92 07:34:11 GMT
- References: <1992Aug31.104950.1108@bohra.cpg.oz.au> <4722@prcrs.prc.com>
- Sender: news@sicsun.epfl.ch
- Organization: Ecole Polytechnique Federale de Lausanne
- Lines: 40
-
- In article <4722@prcrs.prc.com>, paul@prcrs.prc.com (Paul Hite) writes:
- |>
- |> 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!)
-
- I have seen this behaviour before, i mistakenly gave the actual structure
- instead of its address as a parameter to a function call and it worked when
- compiled without -O and broke with -O. (it's hard to debug because it works
- with -g). In this case, it is definetely not the optimiser which is broken,
- but the compiler itself. It looks like it tries to be too much clever.
-
- --
-
-
- Claude Lecommandeur
- Service Informatique Central
- Ecole Polytechnique Federale de Lausanne
- 1015 LAUSANNE (SWITZERLAND)
- E-Mail : lecom@sic.epfl.ch
- Tel : (41 21) 693-22-97
-