home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18733 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.0 KB

  1. Xref: sparky comp.lang.c:18733 comp.unix.bsd:10491
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!Germany.EU.net!rrz.uni-koeln.de!unidui!du9ds3!veit
  3. From: veit@du9ds3.fb9dv.uni-duisburg.de (Holger Veit)
  4. Newsgroups: comp.lang.c,comp.unix.bsd
  5. Subject: Re: Segmentation faults
  6. Date: 21 Dec 92 08:11:12 GMT
  7. Organization: Uni-Duisburg FB9 Datenverarbeitung
  8. Lines: 36
  9. Message-ID: <veit.724925472@du9ds3>
  10. References: <1gricmINNsl@ub.d.umn.edu> <1992Dec18.134225.20548@Logix.DE>
  11. Reply-To: veit@du9ds3.fb9dv.uni-duisburg.de
  12. NNTP-Posting-Host: du9ds3.fb9dv.uni-duisburg.de
  13.  
  14. In <1992Dec18.134225.20548@Logix.DE> jpm@Logix.DE (Jan-Piet Mens) writes:
  15.  
  16. >In <1gricmINNsl@ub.d.umn.edu> cbusch@ub.d.umn.edu (Chris) writes:
  17. >>    Why is the following code producing a segmentation fault???
  18. >>I am compiling this code on an Encore Multimax running UMAX 4.3 Unix.
  19.  
  20. >Doesn't matter where you compile it is bad anyway...
  21.  
  22. >void writexy(x,y,s)
  23. >int x, y;
  24. >char *s;                /* OTHERWISE DEFAULTS TO int !!! */
  25. >{
  26. >   printf("\33[%d;%dH%s",y,x,s);
  27. >}
  28.  
  29. >[ BTW, how about termcap/terminfo ? ]
  30. >-- 
  31. >    __  _____   __  __ 
  32. >   |  ||  _  \ |  \/  |    Logix GmbH                             jpm@Logix.DE
  33. > __|  ||  ___/ |      |    Moritzstrasse 50, +49-611-309797   jpm@logixwi.UUCP
  34. >|_____||__|    |__||__|    D-6200 Wiesbaden  ...!uunet!mcsun!unido!logixwi!jpm
  35.  
  36. This is a real problem where sizeof(int) != sizeof(char*), for instance with
  37. Turbo C or Microsoft C or similar 16bit junk. But if you compile this
  38. with a 32bit K&R compiler, and sizeof(int)==sizeof(char*) (=4), it won't see 
  39. a difference, because it will just take 32bit from the parameter stack 
  40. and push it as a 32bit argument to printf.
  41. The compiler cannot find out the real expected type (it cannot do parsing
  42. of the format string in general!).
  43.  
  44. Holger
  45. -- 
  46. |  |   / Dr. Holger Veit         | INTERNET: veit@du9ds3.fb9dv.uni-duisburg.de
  47. |__|  /  University of Duisburg  |
  48. |  | /   Dept. of Electr. Eng.   |          "Understand me correctly:
  49. |  |/    Inst. f. Dataprocessing |     I'm NOT the WIZARD OF OS" (Holger)
  50.