home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / folklore / computer / 16662 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.7 KB  |  41 lines

  1. Newsgroups: alt.folklore.computers
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!ukma!netnews.louisville.edu!starbase.spd.louisville.edu!aldavi01
  3. From: aldavi01@terra.spd.louisville.edu (Arlie Davis)
  4. Subject: Re: Computer Superstition
  5. Sender: news@netnews.louisville.edu (Netnews)
  6. Message-ID: <aldavi01.722544719@starbase.spd.louisville.edu>
  7. Date: Mon, 23 Nov 1992 18:51:59 GMT
  8. Reply-To: Arlie Davis <aldavi01@starbase.spd.louisville.edu>
  9. References: <10292323.7317.11306@kcbbs.gen.nz> <1992Nov18.124517@frej.teknikum.uu.se> <1992Nov20.015335.19860@fcom.cc.utah.edu>
  10. Nntp-Posting-Host: terra.spd.louisville.edu
  11. Organization: University of Louisville
  12. Lines: 27
  13.  
  14. In <1992Nov20.015335.19860@fcom.cc.utah.edu> bcc@lanai.Eyring.COM (Brian Cooper) writes:
  15.  
  16. > Ah, but sometimes the magic goes away!  I was writing a program where I
  17. > deliberately used this technique to increase the stack space between
  18. > recursive invocations and it wouldn't work.  Come to find out, two 
  19. > different compilers for two different systems optimized my code by
  20. > removing the dummy array.  Quietly, without any fanfare, the compiler
  21. > altered the meaning of my code.  Logic dictates that if the variable is
  22. > never referenced, it must not need to be there, right!?  I included a
  23. > stupid reference to the dummy variable and the program worked.  I recommend
  24.  
  25. >     char magic[12];
  26. >     magic[0] = magic[1];
  27.  
  28. > for modern wizards.
  29.  
  30. Yes, but the latest, greatest super-swanky optimizing compiler may realize
  31. that only the first two elements in the array are being used.  So, you have to
  32. use the more exotic form:
  33.  
  34.     char magic[12];
  35.     magic[0] = magic[11];
  36.  
  37. And if a compiler can squeeze /that/ down, well, I give up.
  38.  
  39. -- 
  40. lrwx------   1 aldavi01 emacsstu       9 Jun  6 12:43 .signature -> /dev/null
  41.