diff --git a/src/snc/gen_ss_code.c b/src/snc/gen_ss_code.c
index 6a7c88a40756caf33629b699bf42a316c472680c..939cce8e7d09211eb964fa1185852fa5954486c6 100644
--- a/src/snc/gen_ss_code.c
+++ b/src/snc/gen_ss_code.c
@@ -535,11 +535,8 @@ static void gen_expr(
 		gen_var_decl(ep->extra.e_decl);
 		break;
 	default:
-#ifdef DEBUG
-		report_at_expr(ep, "unhandled expression (%s:%s)\n",
+		assert_at_expr(impossible, ep, "unhandled expression (%s:%s)\n",
 			expr_type_name(ep), ep->value);
-#endif
-		assert(impossible);
 	}
 }
 
diff --git a/src/snc/main.c b/src/snc/main.c
index cf7bc13d4550d14a24fd202911cb041273fbec28..80be2ccb256de1dce17b61b093dc9f0832e226dd 100644
--- a/src/snc/main.c
+++ b/src/snc/main.c
@@ -270,6 +270,22 @@ void error_at(const char *src_file, int line_num, const char *format, ...)
 	va_end(args);
 }
 
+/* location plus message and report a bug in snc */
+void assert_at(int cond, const char *src_file, int line_num, const char *format, ...)
+{
+	if (!cond)
+	{
+		va_list args;
+
+		report_loc(src_file, line_num);
+		fprintf(stderr, "snc bug (assertion failed): ");
+		va_start(args, format);
+		vfprintf(stderr, format, args);
+		va_end(args);
+		exit(EXIT_FAILURE);
+	}
+}
+
 void report_at_expr(Expr *ep, const char *format, ...)
 {
 	va_list args;
@@ -307,6 +323,22 @@ void error_at_expr(Expr *ep, const char *format, ...)
 	va_end(args);
 }
 
+/* with location from this expression and report a bug in snc */
+void assert_at_expr(int cond, struct expression *ep, const char *format, ...)
+{
+	if (!cond)
+	{
+		va_list args;
+
+		report_loc(ep->src_file, ep->line_num);
+		fprintf(stderr, "snc bug (assertion failed): ");
+		va_start(args, format);
+		vfprintf(stderr, format, args);
+		va_end(args);
+		exit(EXIT_FAILURE);
+	}
+}
+
 void report(const char *format, ...)
 {
 	va_list args;
diff --git a/src/snc/main.h b/src/snc/main.h
index e6d1fe3a7e1c6893a3cdf94f4393b0649c7e17ac..0911de824af7c79a564296a1ef2102a193a23596 100644
--- a/src/snc/main.h
+++ b/src/snc/main.h
@@ -39,6 +39,10 @@ __attribute__((format(printf,3,4)));
 void error_at(const char *src_file, int line_num, const char *format, ...)
 __attribute__((format(printf,3,4)));
 
+/* location plus message and report a bug in snc */
+void assert_at(int cond, const char *src_file, int line_num, const char *format, ...)
+__attribute__((format(printf,4,5)));
+
 /* with location from this expression */
 struct expression;
 void report_at_expr(struct expression *ep, const char *format, ...)
@@ -52,6 +56,10 @@ __attribute__((format(printf,2,3)));
 void error_at_expr(struct expression *ep, const char *format, ...)
 __attribute__((format(printf,2,3)));
 
+/* with location from this expression and report a bug in snc */
+void assert_at_expr(int cond, struct expression *ep, const char *format, ...)
+__attribute__((format(printf,3,4)));
+
 /* message only */
 void report(const char *format, ...)
 __attribute__((format(printf,1,2)));