diff --git a/tccpp.c b/tccpp.c
index 1f46c4a2..e2ba07f7 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -352,6 +352,7 @@ ST_INLN char *unicode_to_utf8 (char *b, uint32_t Uc)
     else if (Uc-0xd800u<0x800) return b;
     else if (Uc<0x10000) *b++=224+Uc/4096, *b++=128+Uc/64%64, *b++=128+Uc%64;
     else if (Uc<0x110000) *b++=240+Uc/262144, *b++=128+Uc/4096%64, *b++=128+Uc/64%64, *b++=128+Uc%64;
+    else tcc_error("0x%x is not a valid universal character", Uc);
     return b;
 }
 
diff --git a/tests/tests2/60_errors_and_warnings.c b/tests/tests2/60_errors_and_warnings.c
index 9cede328..1fa3a56d 100644
--- a/tests/tests2/60_errors_and_warnings.c
+++ b/tests/tests2/60_errors_and_warnings.c
@@ -442,4 +442,10 @@ int f() { ({ return 78; }); }
 int main() { return f(); }
 
 /******************************************************************/
+
+#elif defined test_illegal_unicode
+int main() {
+    char *str = "\Uffffffff";
+}
+
 #endif
diff --git a/tests/tests2/60_errors_and_warnings.expect b/tests/tests2/60_errors_and_warnings.expect
index ac8a9653..a1f854de 100644
--- a/tests/tests2/60_errors_and_warnings.expect
+++ b/tests/tests2/60_errors_and_warnings.expect
@@ -216,3 +216,6 @@ arg[1] = "Y"
 
 [test_return_from_statement_expr]
 [returns 78]
+
+[test_illegal_unicode]
+60_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character