3 Replies Latest reply: May 8, 2012 1:09 PM by C Project Lead RSS

    cc got assertion error, when compiling emacs-23.3

    933091
      I got an assertion error with cc as follows, when compiling emacs-23.3.
      It compiles fine without the "-O" option.
      I can provide a CPP processed file which reproduces it.

      ;; I could not find a place to report bugs, and I put it here.
      ;; Sorry if it is not an appropriate place.

      % cc -V
      cc: Sun C 5.12 SunOS_i386 2011/11/16

      % cc -c -Demacs -DHAVE_CONFIG_H -I. -I/work/emacs/emacs-23.3/src -I/usr/dt/include -g -O font.c
      "font.c", line 185: warning: integer overflow detected: op "<<"
      "font.c", line 197: warning: integer overflow detected: op "<<"
      "font.c", line 215: warning: integer overflow detected: op "<<"
      "font.c", line 2995: warning: integer overflow detected: op "<<"
      "font.c", line 3422: warning: integer overflow detected: op "<<"
      "font.c", line 3920: warning: assignment type mismatch:
      pointer to char "=" pointer to unsigned char
      "font.c", line 3945: warning: assignment type mismatch:
      pointer to char "=" pointer to unsigned char
      "font.c", line 4026: warning: integer overflow detected: op "<<"

      assertion failed in function pg_first_pass_do_block_rec() @ post_gen.c:3758
      assert(blk_sp_offset_(nextb) == (current_offset + get_prologue_size() + BITS2BYTES(be_cur_local_size)))

      cc: ube failed for font.c
        • 1. Re: cc got assertion error, when compiling emacs-23.3
          C Project Lead
          Yes please provide the preprocessed file that reproduces the issue.
          If you can narrow it down to a small testcase that would be appreciated.
          • 2. Re: cc got assertion error, when compiling emacs-23.3
            933091
            The code is large, so I put it at [fontpp.c|http://www.yl.is.s.u-tokyo.ac.jp/~matu/fontpp.c].
            Please take it. (I will soon remove it, maybe after a week.)
            I hope it will help. Thanks.
            • 3. Re: cc got assertion error, when compiling emacs-23.3
              C Project Lead
              Got it ...

              Reduced testcase:

              % cat c.c
              enum Lisp_Type
              {
              Lisp_Int0 = 0,
              Lisp_Float = 7,
              };

              struct Lisp_Float
              {
              union
              {
              double data;
              struct Lisp_Float *chain;
              } u;
              };


              struct Lisp_Vector
              {
              unsigned int size;
              struct Lisp_Vector *next;
              int contents[1];
              };

              int
              font_unparse_xlfd (font, pixel_size, name, nbytes)
              int font;
              int pixel_size;
              char *name;
              int nbytes;
              {
              char *f[21];
              int val;
              int i, j, len = 0;



              val = ( ( struct Lisp_Vector * ) ( ( unsigned int ) ( ( ( font ) ) & ( ( ( ( int ) 1 ) << ( 32 - 3 ) ) - 1 ) ) ) ) -> contents [ 5 ];
              if ( ( ( ( enum Lisp_Type ) ( ( ( unsigned int ) ( ( val ) ) ) >> ( 32 - 3 ) ) ) == Lisp_Float ))
              {
              i = ( ( ( void ) 0 , ( struct Lisp_Float * ) ( ( unsigned int ) ( ( val ) & ( ( ( ( int ) 1 ) << ( 32 - 3 ) ) - 1 ) ) ) ) -> u . data + 0 ) * 10;
              f[2] = __builtin_alloca ( 12 );
              }
              else
              f[2] = "*-*", len += 4;


              }
              % cc -g -O c.c -V
              cc: Sun C 5.12 SunOS_i386 2011/11/16
              acomp: Sun C 5.12 SunOS_i386 2011/11/16
              "c.c", line 41: warning: implicit function declaration: __builtin_alloca
              "c.c", line 41: warning: improper pointer/integer combination: op "="
              iropt: Sun Compiler Common 12.3 SunOS_i386 2011/11/16
              ir2hf: Sun Compiler Common 12.3 SunOS_i386 2011/11/16
              ube: Sun Compiler Common 12.3 SunOS_i386 2011/11/16

              assertion failed in function pg_first_pass_do_block_rec() @ post_gen.c:3758
              assert(blk_sp_offset_(nextb) == (current_offset + get_prologue_size() + BITS2BYTES(be_cur_local_size)))

              cc: ube failed for c.c
              %

              Bug 7167252 filed. If we find a work-around I'll post it.