home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gcc / bug / 3132 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.9 KB  |  134 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ggr.co.UK!gml4410
  3. From: gml4410@ggr.co.UK (Lack Mr G M)
  4. Subject: gcc-2.3.3 - bug on SUN for (char *) within a struct
  5. Message-ID: <9301071447.AA12676@uk0x06.ggr.co.uk>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Thu, 7 Jan 1993 14:47:43 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 121
  12.  
  13.      I wish to report a bug in gcc-2.3.3 on a SUN.
  14.      
  15.      I  have  built  gcc-2.3.3 on a Sun Sparcstation at SunOS4.1.1.  The
  16. configure option was "sparc-sun-sunos4.1" and I  used  CFLAGS=-O  during
  17. the makeing, which completed with no errors.
  18.  
  19.      The  following  simple  program dies with a segmentation fault.  It
  20. runs correctly with gcc-2.3.3 on an SG Indigo, with Suns own cc compiler
  21. (and with other c compilers on other platforms). 
  22.  
  23.      It  appears  that the address of the "string-within-a-structure" is
  24. not calculated correctly.  I append the source and the assembler listing
  25. produced by gcc -S. 
  26.  
  27.  
  28. ====================  Begin test source ====================
  29. #include <stdio.h>
  30. #include <string.h>
  31.  
  32. struct button {
  33.          char *str ;
  34.          int  opdisp ;
  35. } ;
  36.  
  37. struct button buttons[2] = {
  38.      { "ab00", 0, },
  39.      { "ab01", 1, },
  40. };
  41.      
  42. void main()
  43. {
  44.  
  45.    printf("Strings are %s and %s\n", buttons[0].str, buttons[1].str);
  46.    strcpy(buttons[0].str, "zz00");
  47.    strcpy(buttons[1].str, "zz01");
  48.    printf("Strings become %s and %s\n", buttons[0].str, buttons[1].str);
  49.    return;
  50. }
  51. ==================== End test source ====================
  52.  
  53. ==================== Begin assembler listing ====================
  54. gcc2_compiled.:
  55.     .global _buttons
  56. .text
  57.     .align 8
  58. LC0:
  59.     .ascii "ab00\0"
  60.     .align 8
  61. LC1:
  62.     .ascii "ab01\0"
  63. .data
  64.     .align 4
  65. _buttons:
  66.     .word    LC0
  67.     .word    0
  68.     .word    LC1
  69.     .word    1
  70. .text
  71.     .align 8
  72. LC2:
  73.     .ascii "Strings are %s and %s\12\0"
  74.     .align 8
  75. LC3:
  76.     .ascii "zz00\0"
  77.     .align 8
  78. LC4:
  79.     .ascii "zz01\0"
  80.     .align 8
  81. LC5:
  82.     .ascii "Strings become %s and %s\12\0"
  83.     .align 4
  84.     .global _main
  85.     .proc    020
  86. _main:
  87.     !#PROLOGUE# 0
  88.     save %sp,-136,%sp
  89.     !#PROLOGUE# 1
  90.     call ___main,0
  91.     nop
  92.     sethi %hi(_buttons),%o1
  93.     sethi %hi(_buttons+8),%o2
  94.     sethi %hi(LC2),%o3
  95.     or %o3,%lo(LC2),%o0
  96.     ld [%o1+%lo(_buttons)],%o1
  97.     ld [%o2+%lo(_buttons+8)],%o2
  98.     call _printf,0
  99.     nop
  100.     sethi %hi(_buttons),%o1
  101.     ld [%o1+%lo(_buttons)],%o0
  102.     sethi %hi(LC3),%o2
  103.     or %o2,%lo(LC3),%o1
  104.     call _strcpy,0
  105.     nop
  106.     sethi %hi(_buttons+8),%o1
  107.     ld [%o1+%lo(_buttons+8)],%o0
  108.     sethi %hi(LC4),%o2
  109.     or %o2,%lo(LC4),%o1
  110.     call _strcpy,0
  111.     nop
  112.     sethi %hi(_buttons),%o1
  113.     sethi %hi(_buttons+8),%o2
  114.     sethi %hi(LC5),%o3
  115.     or %o3,%lo(LC5),%o0
  116.     ld [%o1+%lo(_buttons)],%o1
  117.     ld [%o2+%lo(_buttons+8)],%o2
  118.     call _printf,0
  119.     nop
  120.     b L1
  121.     nop
  122. L1:
  123.     ret
  124.     restore
  125. ==================== End assembler listing ====================
  126.  
  127.  
  128.  
  129.  
  130. -------------------------- Gordon Lack ----------------------------------
  131. The contents of this message *may* reflect my personal opinion.  They are
  132. *not* intended to reflect those of my employer, or anyone else.
  133.  
  134.