This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

egcs-19990920 cpp broken with long comments embedded in macros


This is a really serious problem that does not exist in 2.95.1.

XEmacs 21.2.19 does not compile with gcc-19990920, but does with
2.95.1.

gcc -E generates files containing embedded null characters.  Buffer overflow?

The long comment in the following is necessary to demonstrate the
bug.  If the comment is reduced in size by half, the problem goes
away.  If the last line of the comment is deleted, I get the new error

cpp-bug.c:177: unterminated string or character constant
cpp-bug.c:36: unterminated string or character constant
cpp-bug.c:36: possible real start of unterminated constant

On another source file in XEmacs, I get:

/hack/import/egcs-19990920/inst/linux-libc2/bin/gcc -c -mcpu=pentiumpro -march=pentiumpro -fno-exceptions -O3 -Wall -Wpointer-arith -Winline -Wmissing-prototypes -Wmissing-declarations -Wunused -Wformat -Wno-switch -Wno-sign-compare -Wno-uninitialized -Wshadow  -Demacs -I. -DHAVE_CONFIG_H -I/usr/local/include -I/usr/X11R6/include /home/martin/x/ws/lwlib/src/glyphs.c
gcc: Internal compiler error: program cpp got fatal signal 6

which is surely related.

Shell transcript follows:


(martin@lasker) ~/src $ /hack/import/egcs-19990920/inst/linux-libc2/bin/gcc -v -E -o cpp-bug.i cpp-bug.c
Reading specs from /hack/import/egcs-19990920/inst/linux-libc2/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 19990920 (experimental)
 /hack/import/egcs-19990920/inst/linux-libc2/lib/gcc-lib/i686-pc-linux-gnu/2.96/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentiumpro__ cpp-bug.c -o cpp-bug.i
GNU CPP version 2.96 19990920 (experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /hack/import/egcs-19990920/inst/include
 /hack/import/egcs-19990920/inst/linux-libc2/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../i686-pc-linux-gnu/include
 /hack/import/egcs-19990920/inst/linux-libc2/lib/gcc-lib/i686-pc-linux-gnu/2.96/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /hack/import/egcs-19990920/inst/linux-libc2/lib/gcc-lib/i686-pc-linux-gnu/2.96/../../../../../include/g++-3
End of omitted list.
(martin@lasker) ~/src $ od -c cpp-bug.i | head -30
0000000   #       1       "   c   p   p   -   b   u   g   .   c   "  \n
0000020  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n
*
0000060  \n  \n  \n   L   i   s   p   _   O   b   j   e   c   t        
0000100       F   s   e   t   _   e   x   t   e   n   t   _   p   r   o
0000120   p   e   r   t   y           (   L   i   s   p   _   O   b   j
0000140   e   c   t   ,   L   i   s   p   _   O   b   j   e   c   t   ,
0000160   L   i   s   p   _   O   b   j   e   c   t           )   ;  \t
0000200   s   t   a   t   i   c       s   t   r   u   c   t       L   i
0000220   s   p   _   S   u   b   r       S   F   s   e   t   _   e   x
0000240   t   e   n   t   _   p   r   o   p   e   r   t   y           =
0000260       {       s   u   b   r   _   l   h   e   a   d   e   r   _
0000300   i   n   i   t   i   a   l   i   z   e   r   ,  \t           3
0000320       ,               3       ,               0       ,       0
0000340   ,           "   s   e   t   -   e   x   t   e   n   t   -   p
0000360   r   o   p   e   r   t   y   "       ,       (   l   i   s   p
0000400   _   f   n   _   t   )               F   s   e   t   _   e   x
0000420   t   e   n   t   _   p   r   o   p   e   r   t   y           }
0000440   ;  \t   L   i   s   p   _   O   b   j   e   c   t            
0000460   F   s   e   t   _   e   x   t   e   n   t   _   p   r   o   p
0000500   e   r   t   y           (   D   E   F   U   N   _   3        
0000520      \0  \0 006  \0  \0  \0   !  \0  \0  \0  \0  \0  \0  \0  \0
0000540  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0 016
0000560  \0  \0  \0  \a  \0  \0  \0   !  \0  \0  \0   h   ,       g   ,
0000600       f   ,       e   ,       d   ,       c   ,       b   ,    
0000620   a  \0  \0  \0  \0  \0  \0   )  \0  \0  \0  \0  \0  \0  \0  \0
0000640  \0  \0  \0   Ø   F 006  \b   "  \0  \0  \0  \a  \0  \0  \0   Ü
0000660   Ù 006  \b   H   Ø 006  \b   D   E   F   U   N   _   8  \0   Y
0000700 035  \0  \0  \0  \0 006  \0  \0  \0   !  \0  \0  \0  \0  \0  \0
0000720  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
(martin@lasker) ~/src $ cat cpp-bug.c
#define EXFUN_0 void
#define EXFUN_1 Lisp_Object
#define EXFUN_2 Lisp_Object,Lisp_Object
#define EXFUN_3 Lisp_Object,Lisp_Object,Lisp_Object
#define EXFUN_4 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object
#define EXFUN_5 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object
#define EXFUN_6 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \
Lisp_Object
#define EXFUN_7 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \
Lisp_Object,Lisp_Object
#define EXFUN_8 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \
Lisp_Object,Lisp_Object,Lisp_Object
#define EXFUN_MANY int, Lisp_Object*
#define EXFUN_UNEVALLED Lisp_Object
#define EXFUN(sym, max_args) Lisp_Object sym (EXFUN_##max_args)

#define DEFUN(lname, Fname, min_args, max_args, prompt, arglist)	\
  Lisp_Object Fname (EXFUN_##max_args);					\
  static struct Lisp_Subr S##Fname = { subr_lheader_initializer,	\
	min_args, max_args, prompt, 0, lname, (lisp_fn_t) Fname };	\
  Lisp_Object Fname (DEFUN_##max_args arglist)

#define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object
#define DEFUN_UNEVALLED(args) Lisp_Object args
#define DEFUN_0() void
#define DEFUN_1(a)					Lisp_Object a
#define DEFUN_2(a,b)		 DEFUN_1(a),		Lisp_Object b
#define DEFUN_3(a,b,c)		 DEFUN_2(a,b),		Lisp_Object c
#define DEFUN_4(a,b,c,d)	 DEFUN_3(a,b,c),	Lisp_Object d
#define DEFUN_5(a,b,c,d,e)	 DEFUN_4(a,b,c,d),	Lisp_Object e
#define DEFUN_6(a,b,c,d,e,f)	 DEFUN_5(a,b,c,d,e),	Lisp_Object f
#define DEFUN_7(a,b,c,d,e,f,g)	 DEFUN_6(a,b,c,d,e,f),	Lisp_Object g
#define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g),Lisp_Object h


DEFUN ("set-extent-property", Fset_extent_property, 3, 3, 0, /*
Change a property of an extent.
PROPERTY may be any symbol; the value stored may be accessed with
 the `extent-property' function.
The following symbols have predefined meanings:

 detached           Removes the extent from its buffer; setting this is
                    the same as calling `detach-extent'.

 destroyed          Removes the extent from its buffer, and makes it
                    unusable in the future; this is the same calling
                    `delete-extent'.

 priority           Change redisplay priority; same as `set-extent-priority'.

 start-open         Whether the set of characters within the extent is
                    treated being open on the left, that is, whether
                    the start position is an exclusive, rather than
                    inclusive, boundary.  If true, then characters
                    inserted exactly at the beginning of the extent
                    will remain outside of the extent; otherwise they
                    will go into the extent, extending it.

 end-open           Whether the set of characters within the extent is
                    treated being open on the right, that is, whether
                    the end position is an exclusive, rather than
                    inclusive, boundary.  If true, then characters
                    inserted exactly at the end of the extent will
                    remain outside of the extent; otherwise they will
                    go into the extent, extending it.

                    By default, extents have the `end-open' but not the
                    `start-open' property set.

 read-only          Text within this extent will be unmodifiable.

 initial-redisplay-function (EXPERIMENTAL)
                    function to be called the first time (part of) the extent
                    is redisplayed. It will be called with the extent as its
                    first argument.
		    Note: The function will not be called immediately
		    during redisplay, an eval event will be dispatched.

 detachable         Whether the extent gets detached (as with
                    `detach-extent') when all the text within the
                    extent is deleted.  This is true by default.  If
                    this property is not set, the extent becomes a
                    zero-length extent when its text is deleted. (In
                    such a case, the `start-open' property is
                    automatically removed if both the `start-open' and
                    `end-open' properties are set, since zero-length
                    extents open on both ends are not allowed.)

 face               The face in which to display the text.  Setting
                    this is the same as calling `set-extent-face'.

 mouse-face	    If non-nil, the extent will be highlighted in this
		    face when the mouse moves over it.

 pointer            If non-nil, and a valid pointer glyph, this specifies
                    the shape of the mouse pointer while over the extent.

 highlight          Obsolete: Setting this property is equivalent to
		    setting a `mouse-face' property of `highlight'.
		    Reading this property returns non-nil if
		    the extent has a non-nil `mouse-face' property.

 duplicable         Whether this extent should be copied into strings,
                    so that kill, yank, and undo commands will restore
                    or copy it.  `duplicable' extents are copied from
                    an extent into a string when `buffer-substring' or
                    a similar function creates a string.  The extents
                    in a string are copied into other strings created
                    from the string using `concat' or `substring'.
                    When `insert' or a similar function inserts the
                    string into a buffer, the extents are copied back
                    into the buffer.

 unique             Meaningful only in conjunction with `duplicable'.
                    When this is set, there may be only one instance
                    of this extent attached at a time: if it is copied
                    to the kill ring and then yanked, the extent is
                    not copied.  If, however, it is killed (removed
                    from the buffer) and then yanked, it will be
                    re-attached at the new position.

 invisible          If the value is non-nil, text under this extent
                    may be treated as not present for the purpose of
                    redisplay, or may be displayed using an ellipsis
                    or other marker; see `buffer-invisibility-spec'
                    and `invisible-text-glyph'.  In all cases,
                    however, the text is still visible to other
                    functions that examine a buffer's text.

 keymap             This keymap is consulted for mouse clicks on this
                    extent, or keypresses made while point is within the
                    extent.

 copy-function      This is a hook that is run when a duplicable extent
                    is about to be copied from a buffer to a string (or
                    the kill ring).  It is called with three arguments,
                    the extent, and the buffer-positions within it
                    which are being copied.  If this function returns
                    nil, then the extent will not be copied; otherwise
                    it will.

 paste-function     This is a hook that is run when a duplicable extent is
                    about to be copied from a string (or the kill ring)
                    into a buffer.  It is called with three arguments,
                    the original extent, and the buffer positions which
                    the copied extent will occupy.  (This hook is run
                    after the corresponding text has already been
                    inserted into the buffer.)  Note that the extent
                    argument may be detached when this function is run.
                    If this function returns nil, no extent will be
                    inserted.  Otherwise, there will be an extent
                    covering the range in question.

                    If the original extent is not attached to a buffer,
                    then it will be re-attached at this range.
                    Otherwise, a copy will be made, and that copy
                    attached here.

                    The copy-function and paste-function are meaningful
                    only for extents with the `duplicable' flag set,
                    and if they are not specified, behave as if `t' was
                    the returned value.  When these hooks are invoked,
                    the current buffer is the buffer which the extent
                    is being copied from/to, respectively.

 begin-glyph        A glyph to be displayed at the beginning of the extent,
                    or nil.

 end-glyph          A glyph to be displayed at the end of the extent,
                    or nil.

 begin-glyph-layout The layout policy (one of `text', `whitespace',
                    `inside-margin', or `outside-margin') of the extent's
                    begin glyph.

 end-glyph-layout The layout policy of the extent's end glyph.
*/
       (extent, property, value))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]