SourceForge.net Logo

[Release b]
<t4m_bug_foo_bar>
(Not fixed)
Sat May  8 10:17:23 WEST 2004

In the current release of tendra4minix (a) (and also in the original 4.1.2
version), the compilation of the program foo_bar.C produces the following error

Internal error: 'tag 1' used but not defined.

It is bug3 of http://www.ten15.org. The problem arises in the function
add_compound_stmt [statement.c], and I think that it is very difficult to
solve.

To understand it, here is a trace of the calls to the function
add_compound_stmt for the program

void hola(void) {
  int uno;
  double dos;
  long double tres;
}

add_compound_stmt, ns = hola, nspace_last = uno,  nspace_prev = <param1>
add_compound_stmt, ns = hola, nspace_last = dos,  nspace_prev = uno
add_compound_stmt, ns = hola, nspace_last = tres, nspace_prev = dos
add_compound_stmt, ns = hola, nspace_last = tres, nspace_prev = tres
add_compound_stmt, ns = hola, nspace_last = tres, nspace_prev = tres

An invocation of add_compound_stmt with EQ_member(p, q), where

	MEMBER p = DEREF_member ( nspace_last ( ns ) ) ;
	MEMBER q = DEREF_member ( nspace_prev ( ns ) ) ;

makes the compiler skip a call to the function make_decl_stmt [statement.c],
and this is happening spuriously in foo_bar.C,

void bla(void) {
        struct foo { int bar; };
        static struct foo foo;
        struct foo bar = foo;
}

add_compound_stmt, ns = bla, nspace_last = ,    nspace_prev = <param1>
add_compound_stmt, ns = bla, nspace_last = foo, nspace_prev = foo
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = foo
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = bar
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = bar

The second line of this trace is wrong: nspace_prev should be NULL; this is
what happens in foo_bar_e.C, where we have changed the name of the variable
from 'foo' to 'fo',

void bla(void) {
        struct foo { int bar; };
        static struct foo fo;
        struct foo bar = fo;
}

add_compound_stmt, ns = bla, nspace_last = ,    nspace_prev = <param1>
add_compound_stmt, ns = bla, nspace_last = fo,  nspace_prev =
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = fo
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = bar
add_compound_stmt, ns = bla, nspace_last = bar, nspace_prev = bar

The wrong call (where nspace_last is equal to nspace_prev) is made from the
parser, more specifically, from line 1132 of the file
src/producers/c/syntax/syntax3.c,

    (ZI448) = add_compound_stmt ( (ZI467), (ZI416) ) ;

but this is a sid-generated file, and I do not have time to mess with neither
sid nor the infamous C++ syntax. Besides, this bug is not important since the
program is pathological.