diff --git a/tccpp.c b/tccpp.c
index a5f6d7af..057da007 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1189,6 +1189,7 @@ ST_FUNC void end_macro(void)
     macro_stack = str->prev;
     macro_ptr = str->prev_ptr;
     file->line_num = str->save_line_num;
+    str->len = 0; /* matters if str not alloced, may be tokstr_buf */
     if (str->alloc != 0) {
         if (str->alloc == 2)
             str->str = NULL; /* don't free */
diff --git a/tests/pp/22.c b/tests/pp/22.c
new file mode 100644
index 00000000..76e23154
--- /dev/null
+++ b/tests/pp/22.c
@@ -0,0 +1,12 @@
+#define TRACE(a,b,c) X a X b X c X
+#define rettrue(x) 1
+A rettrue(bla) B
+TRACE(
+      ARG_1,
+#if rettrue(bla)
+      ARG_2,
+#else
+      ARG_2_wrong,
+#endif
+      ARG_3
+);
diff --git a/tests/pp/22.expect b/tests/pp/22.expect
new file mode 100644
index 00000000..ceaea030
--- /dev/null
+++ b/tests/pp/22.expect
@@ -0,0 +1,2 @@
+A 1 B
+X ARG_1 X ARG_2 X ARG_3 X;