gcc-2.95.2 compiler bug:

Tim Janik timj@gtk.org
Thu Oct 14 18:10:00 GMT 1999


hi all,

i just stumbled over a compiler bug on my potato system:

$ uname -a
Linux birgrave 2.2.12 #2 Tue Aug 31 02:49:55 CEST 1999 i586 unknown

$ gcc --version
2.95.2
# dpkg  --print-avail gcc
Package: gcc
Priority: standard
Section: devel
Installed-Size: 2263
Maintainer: Debian GCC maintainers <gcc@packages.debian.org>
Architecture: i386
Source: gcc (2.95.2-0pre2)
Version: 1:2.95.2-0pre2
Replaces: egcc (<< 2.91.63-1.1)
Provides: egcc, c-compiler
Depends: libc6 (>= 2.1), cpp (>= 1:2.95.2), cpp (<< 1:2.95.3), binutils (>= 2.9.1.0.15)
Recommends: libc-dev
Suggests: gcc-doc (>= 1:2.95.2)
Conflicts: libc5-dev, egcc (<< 2.91.63-1.1)
Size: 943262
Description: The GNU C compiler.
 This is the GNU C compiler, a fairly portable optimizing compiler which
 supports multiple languages.  This package includes support for C, C++,
 and Objective C.


i'm getting two types of errors (from majorly stripped down code),
internal compiler error:

$ gcc -I/usr/local/include -I/usr/local/lib/glib/include -g -Wno-cast-qual -Wall
-Wmissing-prototypes -Winline -Wmissing-noreturn -O6 -pipe -fstrength-reduce -fexpensive-optimizations -finline-functions -frerun-cse-after-loop -freg-struct-return -funroll-loops -frerun-loop-opt -fgcse -fno-keep-static-consts -c x.c
x.c:99: macro `BST_DEBUG' used with too many (3) args
x.c:46: warning: no previous prototype for `bst_sample_repo_init'
x.c: In function `bst_sample_repo_init':
x.c:49: `GPatternSpec' undeclared (first use in this function)
x.c:49: (Each undeclared identifier is reported only once
x.c:49: for each function it appears in.)
x.c:49: `pspec' undeclared (first use in this function)
x.c:49: warning: statement with no effect
x.c:53: warning: implicit declaration of function `g_pattern_spec_new'
x.c:54: warning: implicit declaration of function `list_files_rec'
x.c:54: `BST_DATA_DIR' undeclared (first use in this function)
x.c:54: warning: assignment makes pointer from integer without a cast
x.c:55: warning: implicit declaration of function `g_pattern_spec_free'
x.c:76: warning: implicit declaration of function `bst_sample_repo_add_sample'
x.c:76: warning: implicit declaration of function `bst_sample_repo_new'
x.c:82: warning: implicit declaration of function `close'
x.c:90: warning: implicit declaration of function `bst_sample_repo_list_sample_locs'
x.c:90: warning: initialization makes pointer from integer without a cast
x.c:90: warning: unused variable `free_list'
x.c:90: parse error before `)'
In file included from x.c:104:
/usr/include/sys/stat.h:319: Internal compiler error in `identify_blocks', at function.c:5867
Please submit a full bug report.
See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for instructions.


and a bunch of assembler warnings:

$ gcc -I/usr/local/include -I/usr/local/lib/glib/include -g -Wno-cast-qual -Wall
-Wmissing-prototypes -Winline -Wmissing-noreturn -O6 -pipe -c x.c
x.c:99: macro `BST_DEBUG' used with too many (3) args
x.c:46: warning: no previous prototype for `bst_sample_repo_init'
x.c: In function `bst_sample_repo_init':
x.c:49: `GPatternSpec' undeclared (first use in this function)
x.c:49: (Each undeclared identifier is reported only once
x.c:49: for each function it appears in.)
x.c:49: `pspec' undeclared (first use in this function)
x.c:49: warning: statement with no effect
x.c:53: warning: implicit declaration of function `g_pattern_spec_new'
x.c:54: warning: implicit declaration of function `list_files_rec'
x.c:54: `BST_DATA_DIR' undeclared (first use in this function)
x.c:54: warning: assignment makes pointer from integer without a cast
x.c:55: warning: implicit declaration of function `g_pattern_spec_free'
x.c:76: warning: implicit declaration of function `bst_sample_repo_add_sample'
x.c:76: warning: implicit declaration of function `bst_sample_repo_new'
x.c:82: warning: implicit declaration of function `close'
x.c:90: warning: implicit declaration of function `bst_sample_repo_list_sample_locs'
x.c:90: warning: initialization makes pointer from integer without a cast
x.c:90: warning: unused variable `free_list'
x.c:90: parse error before `)'
In file included from x.c:104:
/usr/include/sys/stat.h: At top level:
/usr/include/sys/stat.h:323: warning: `struct stat' declared inside parameter list
/usr/include/sys/stat.h:323: warning: its scope is only this definition or declaration, which is probably not what you want.
/usr/include/sys/stat.h:324: warning: no previous prototype for `lstat'
/usr/include/sys/stat.h: In function `lstat':
/usr/include/sys/stat.h:325: warning: implicit declaration of function `__lxstat'
/usr/include/sys/stat.h: At top level:
/usr/include/sys/stat.h:329: warning: `struct stat' declared inside parameter list
/usr/include/sys/stat.h:330: warning: no previous prototype for `fstat'
/usr/include/sys/stat.h: In function `fstat':
/usr/include/sys/stat.h:331: warning: implicit declaration of function `__fxstat'
/usr/include/sys/stat.h: At top level:
/usr/include/sys/stat.h:337: warning: no previous prototype for `mknod'
/usr/include/sys/stat.h: In function `mknod':
/usr/include/sys/stat.h:338: warning: implicit declaration of function `__xmknod'
x.c: At top level:
x.c:109: parse error before `GPatternSpec'
x.c:110: warning: `list_files_rec' was used with no prototype before its definition
x.c:110: warning: `list_files_rec' was declared implicitly `extern' and later `static'
x.c:54: warning: previous declaration of `list_files_rec'
x.c:110: warning: type mismatch with previous implicit declaration
x.c:54: warning: previous implicit declaration of `list_files_rec'
x.c:110: warning: `list_files_rec' was previously implicitly declared to return `int'
x.c: In function `list_files_rec':
x.c:113: `dir_name' undeclared (first use in this function)
x.c:122: variable `stat_buf' has initializer but incomplete type
x.c:122: warning: excess elements in struct initializer
x.c:122: warning: (near initialization for `stat_buf')
x.c:122: storage size of `stat_buf' isn't known
x.c:125: warning: implicit declaration of function `stat'
x.c:128: `slist' undeclared (first use in this function)
x.c:128: `pspec' undeclared (first use in this function)
x.c:129: warning: implicit declaration of function `g_pattern_match_string'
x.c:122: warning: unused variable `stat_buf'
x.c:141: warning: control reaches end of non-void function
{standard input}: Assembler messages:
{standard input}:587: Error: Subtraction of two symbols in different sections ".LBE2" {*UND* section} - "bst_sample_repo_init" {.text section} at file address 4808.
{standard input}:704: Error: Subtraction of two symbols in different sections ".LBB11" {*UND* section} - "list_files_rec" {.text section} at file address 5216.
{standard input}:706: Error: Subtraction of two symbols in different sections ".LBB12" {*UND* section} - "list_files_rec" {.text section} at file address 5240.
{standard input}:707: Error: Subtraction of two symbols in different sections ".LBE12" {*UND* section} - "list_files_rec" {.text section} at file address 5252.
{standard input}:708: Error: Subtraction of two symbols in different sections ".LBE11" {*UND* section} - "list_files_rec" {.text section} at file address 5264.

the file in question is appended (all those extra warnings are generated
because a bunch of the header files are missing, the same happens with
correct include files and no extra warnings).
you might need glib.h to trigger this, but GLib is a fairly common package
which should either be installed on your system already, or can be retrived
from www.gtk.org.


---
ciaoTJ


/* BEAST - Bedevilled Audio System
 * Copyright (C) 1998, 1999 Olaf Hoehmann and Tim Janik
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
#include <glib.h>

#define G_ENABLE_DEBUG

/* --- debug stuff --- */
typedef enum                    /* <skip> */
{ /* keep in sync with bstmain.c */
  BST_DEBUG_KEYTABLE            = (1 << 0),
  BST_DEBUG_MASTER              = (1 << 1),
  BST_DEBUG_SAMPLES             = (1 << 2)
} BstDebugFlags;
extern BstDebugFlags bst_debug_flags;
#ifdef G_ENABLE_DEBUG
#define BST_DEBUG(type, code)   G_STMT_START { \
  if (bst_debug_flags & BST_DEBUG_##type) \
    { code ; } \
} G_STMT_END
#else  /* !G_ENABLE_DEBUG */
#define BST_DEBUG(type, code)   /* do nothing */
#endif /* !G_ENABLE_DEBUG */


#include <fcntl.h>
#include <errno.h>


void
bst_sample_repo_init (void)
{
  GScanner *scanner;
  GSList *slist, *sample_names = NULL;
  GPatternSpec *pspec;

  BST_DEBUG (SAMPLES, g_message ("Scanning sample repositories..."));

  pspec = g_pattern_spec_new ("*.bse");
  sample_names = list_files_rec (sample_names, BST_DATA_DIR, pspec);
  g_pattern_spec_free (pspec);
  sample_names = g_slist_reverse (sample_names);

  scanner = g_scanner_new (NULL);
  g_scanner_add_symbol (scanner, "BseSample", NULL);
  for (slist = sample_names; slist; slist = slist->next)
    {
      gchar *file_name = slist->data;
      gint fd = open (file_name, O_RDONLY);
      
      if (fd >= 0)
	{
	  g_scanner_input_file (scanner, fd);
	  while (scanner->token != G_TOKEN_EOF)
	    {
	      g_scanner_get_next_token (scanner);
	      if (scanner->token == G_TOKEN_SYMBOL)
		{
		  if (g_scanner_get_next_token (scanner) == ':' &&
		      g_scanner_get_next_token (scanner) == ':' &&
		      g_scanner_get_next_token (scanner) == G_TOKEN_IDENTIFIER)
		    bst_sample_repo_add_sample (bst_sample_repo_new (file_name),
						scanner->value.v_identifier);
		  break;
		}
	      
	    }
	  close (fd);
	}
      g_free (file_name);
    }
  g_scanner_destroy (scanner);
  g_slist_free (sample_names);

  BST_DEBUG (SAMPLES, {
    GList *free_list = bst_sample_repo_list_sample_locs (), *list;

    for (list = free_list; list; list = list->next)
      {
	BstSampleLoc *loc = list->data;
	
	g_print ("%s:: %s\n", loc->repo->name, loc->name);
      }
    g_list_free (free_list);
  });
}

/* --- directory scanning --- */
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
static GSList*
list_files_rec (GSList       *slist,
		const gchar  *dir_name,
		GPatternSpec *pspec)
{
  DIR *dd;

  dd = opendir (dir_name);
  if (dd)
    {
      struct dirent *d_entry = readdir (dd);

      while (d_entry)
	{
	  if (d_entry->d_name[0] != '.')
	    {
	      struct stat stat_buf = { 0, };
	      gchar *name = g_strconcat (dir_name, "/", d_entry->d_name, NULL);
	      
	      stat (name, &stat_buf);
	      
	      if (S_ISDIR (stat_buf.st_mode))
		slist = list_files_rec (slist, name, pspec);
	      else if (S_ISREG (stat_buf.st_mode) && g_pattern_match_string (pspec, name))
		slist = g_slist_prepend (slist, g_strdup (name));

	      g_free (name);
	    }

	  d_entry = readdir (dd);
	}
      closedir (dd);
    }

  return slist;
}



More information about the Gcc-bugs mailing list