Add a generic "internal error" warning function.
diff --git a/src/output.c b/src/output.c
index ae105fb..50d54ce 100644
--- a/src/output.c
+++ b/src/output.c
@@ -485,6 +485,14 @@
     }
 }
 
+// Report a detected internal inconsistency.
+void
+__warn_internalerror(int lineno, const char *fname)
+{
+    dprintf(1, "WARNING - internal error detected at %s:%d!\n"
+            , fname, lineno);
+}
+
 // Report on an allocation failure.
 void
 __warn_noalloc(int lineno, const char *fname)
diff --git a/src/util.h b/src/util.h
index 9c78e4c..9f71d65 100644
--- a/src/util.h
+++ b/src/util.h
@@ -227,6 +227,7 @@
 void __debug_stub(struct bregs *regs, int lineno, const char *fname);
 void __warn_invalid(struct bregs *regs, int lineno, const char *fname);
 void __warn_unimplemented(struct bregs *regs, int lineno, const char *fname);
+void __warn_internalerror(int lineno, const char *fname);
 void __warn_noalloc(int lineno, const char *fname);
 void __warn_timeout(int lineno, const char *fname);
 void __set_invalid(struct bregs *regs, int lineno, const char *fname);
@@ -254,6 +255,8 @@
     __warn_invalid((regs), __LINE__, __func__)
 #define warn_unimplemented(regs)                        \
     __warn_unimplemented((regs), __LINE__, __func__)
+#define warn_internalerror()                    \
+    __warn_internalerror(__LINE__, __func__)
 #define warn_noalloc()                          \
     __warn_noalloc(__LINE__, __func__)
 #define warn_timeout()                          \