Prof A Olowofoyeku (The African Chief) wrote:
I found another bug involving when 2 units use each other - this is probably the same as I reported earlier today.
Unfortunately not.
I have attached a test program. Note that the error is there whether you use the new "initialization" or just "begin end."
This program should output "OK", and does so under BP and Delphi.
First of all, EP does not even allow initializers in mutually dependent modules (for good reasons, since in general the order of execution is not well-defined; e.g., if the main program uses the other unit, they're executed in reverse order, and if it uses both, or uses some other units which in turn use one or both of these, it gets really hairy).
But that's not actually the issue here. The following patch should fix it, but still I'd be very careful with such initializers (especially if their order of execution matters, like here).
--- p/util.c.orig Sat Mar 29 15:02:20 2003 +++ p/util.c Sat Mar 29 15:06:14 2003 @@ -1682,6 +1682,10 @@ expand_start_cond (run_condition, 0); expand_expr_stmt (build_modify_expr (run_condition, NOP_EXPR, boolean_false_node));
+ /* Initialize this module's variables since another module's initializer + could access them (via circular references, though violating EP). */ + un_initialize_block (decls, 0); + for (imported_interface = current_module->imports; imported_interface; imported_interface = TREE_CHAIN (imported_interface)) @@ -1734,7 +1738,6 @@ Pmode); if (current_module->main_program) emit_constructor_call ("_p_DoInitProc"); - un_initialize_block (decls, 0); }
/* Generate special code at the end of a module/unit constructor. */
Frank