aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/initializers.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-11-13 15:42:25 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2015-11-13 15:42:25 +0100
commit9f0fcc2c52d136fb8891f1ce2e135bdb1273df19 (patch)
tree0a536a5e755514cad2acfad746282cadf7f8926c /test/regression/initializers.c
parent3f24b362f5ac2aa252ee14f1b793ebbf2f69ff08 (diff)
downloadcompcert-kvx-9f0fcc2c52d136fb8891f1ce2e135bdb1273df19.tar.gz
compcert-kvx-9f0fcc2c52d136fb8891f1ce2e135bdb1273df19.zip
Issue #71: incorrect initialization of wchar_t arrays from wide string literal
Regression test added in regression/initializers.c
Diffstat (limited to 'test/regression/initializers.c')
-rw-r--r--test/regression/initializers.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/regression/initializers.c b/test/regression/initializers.c
index 31f73734..6c8fadc9 100644
--- a/test/regression/initializers.c
+++ b/test/regression/initializers.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <stdio.h>
int x0;
@@ -67,6 +68,11 @@ char * x25[] = { "/tmp" };
/* One more */
char x26[] = { "world" };
+/* Wide strings (issue #71) */
+wchar_t x27[] = L"abc";
+wchar_t x28[2] = L"abc";
+wchar_t x29[10] = L"abc";
+
static void print_chars(char * s, int sz)
{
int i;
@@ -78,6 +84,17 @@ static void print_chars(char * s, int sz)
}
}
+static void print_wchars(wchar_t * s, int sz)
+{
+ int i;
+ for (i = 0; i < sz; i++) {
+ if (s[i] >= 32 && s[i] < 127)
+ printf("'%c', ", (char) s[i]);
+ else
+ printf("%d, ", (int) s[i]);
+ }
+}
+
int main()
{
int i;
@@ -137,6 +154,15 @@ int main()
printf("x26[%d] = { ", (int) sizeof(x26));
print_chars(x26, sizeof(x26));
printf("}\n");
+ printf("x27[%d] = { ", (int) (sizeof(x27) / sizeof(wchar_t)));
+ print_wchars(x27, sizeof(x27) / sizeof(wchar_t));
+ printf("}\n");
+ printf("x28[%d] = { ", (int) (sizeof(x28) / sizeof(wchar_t)));
+ print_wchars(x28, sizeof(x28) / sizeof(wchar_t));
+ printf("}\n");
+ printf("x29[%d] = { ", (int) (sizeof(x29) / sizeof(wchar_t)));
+ print_wchars(x29, sizeof(x29) / sizeof(wchar_t));
+ printf("}\n");
return 0;
}