[m-rev.] for review: fix failing tabling tests with MSVC

Julien Fischer jfischer at opturion.com
Mon Jul 17 14:44:20 AEST 2023


For review by anyone.

--------------------

Fix failing tabling tests with MSVC.

The tests tabling/fib_string and tabling/unused_args both fail when compiled in
grade none.gc with MSVC. This is due to the code generator emitting an empty
array initializer, which MSVC rejects since it is not standard C.

compiler/llds_out_global.m:
    Output a dummy initializer in the above case.

Julien.

diff --git a/compiler/llds_out_global.m b/compiler/llds_out_global.m
index de7a037..3f04b20 100644
--- a/compiler/llds_out_global.m
+++ b/compiler/llds_out_global.m
@@ -313,7 +313,15 @@ output_table_steps_table(Info, Stream, DataId, StepDescs, !IO) :-
      io.write_string(Stream, "static const MR_TableStepDesc ", !IO),
      output_data_id(Info, Stream, DataId, !IO),
      io.write_string(Stream, "[] = {\n", !IO),
-    output_table_steps(Stream, StepDescs, !IO),
+    (
+        % ISO C does not allow empty arrays, so place a dummy value in the
+        % array if necessary.
+        StepDescs = [],
+        io.write_string(Stream, "{0}", !IO)
+    ;
+        StepDescs = [_ | _],
+        output_table_steps(Stream, StepDescs, !IO)
+    ),
      io.write_string(Stream, "};\n", !IO).

  :- pred output_table_steps(io.text_output_stream::in,





More information about the reviews mailing list