home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / hp / 10048 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  2.4 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!slhp1.epfl.ch!lecom
  2. From: lecom@slhp1.epfl.ch (Claude Lecommandeur)
  3. Newsgroups: comp.sys.hp
  4. Subject: Re: that HPUX cc compiler
  5. Message-ID: <3939@sicsun.epfl.ch>
  6. Date: 4 Sep 92 07:34:11 GMT
  7. References: <1992Aug31.104950.1108@bohra.cpg.oz.au> <4722@prcrs.prc.com>
  8. Sender: news@sicsun.epfl.ch
  9. Organization: Ecole Polytechnique Federale de Lausanne
  10. Lines: 40
  11.  
  12. In article <4722@prcrs.prc.com>, paul@prcrs.prc.com (Paul Hite) writes:
  13. |> 
  14. |> HP gets a lot of grief from the behavior of their c optimizer.  I'm sure
  15. |> that some of it is valid.  But a lot of the posts basicly say something
  16. |> like:
  17. |>     I've got a program that works without the optimizer and fails
  18. |>     when I optimize it.  Therefore HP's optimizer is broken.
  19. |> 
  20. |> Here's a real live counter-example to that argument.  I wrote a replacement
  21. |> to w and it worked without the optimizer and failed when I optimized it.
  22. |> I reduced the program to a tiny example that also failed with the optimizer.
  23. |> The complete program is below my signature, but here is the important part:
  24. |>     struct utmp entry;
  25. |>     while(fread(entry, sizeof entry, 1, u)) {
  26. |>         bogus = entry.ut_time;
  27. |> With the optimizer, bogus always had the same value.  Without the optimizer
  28. |> various correct values are printed.  The problem is the fread.  It should be:
  29. |>     while(fread(&entry, sizeof entry, 1, u)) {
  30. |>                 ^
  31. |> And the optimizer works fine on the corrected program.  Actually it's amazing
  32. |> that the program works at all the first way.  All of this is on an 847, those
  33. |> of you on other platforms may get different results with the buggy program.
  34. |> (Indeed, Steinar Haug found the bug for me as he struggled to get my program
  35. |> working on a 425!)
  36.  
  37.     I have seen this behaviour before, i mistakenly gave the actual structure
  38. instead of its address as a parameter to a function call and it worked when
  39. compiled without -O and broke with -O. (it's hard to debug because it works
  40. with -g). In this case, it is definetely not the optimiser which is broken,
  41. but the compiler itself. It looks like it tries to be too much clever.
  42.  
  43. -- 
  44.  
  45.  
  46.                     Claude Lecommandeur
  47.                     Service Informatique Central
  48.                     Ecole Polytechnique Federale de Lausanne
  49.                     1015 LAUSANNE (SWITZERLAND)
  50.                     E-Mail : lecom@sic.epfl.ch
  51.                     Tel : (41 21) 693-22-97
  52.