diff --git a/c-tests/new/issue362.c b/c-tests/new/issue362.c new file mode 100644 index 0000000000..1f17c6a4f9 --- /dev/null +++ b/c-tests/new/issue362.c @@ -0,0 +1,4 @@ +n () { + char* p; + int m = {}; +} diff --git a/c-tests/new/issue362.c.expectrc b/c-tests/new/issue362.c.expectrc new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/c-tests/new/issue362.c.expectrc @@ -0,0 +1 @@ +1 diff --git a/c2mir/c2mir.c b/c2mir/c2mir.c index 64f9ac3ea0..418ab477ea 100644 --- a/c2mir/c2mir.c +++ b/c2mir/c2mir.c @@ -7698,7 +7698,10 @@ static void check_initializer (c2m_ctx_t c2m_ctx, decl_t member_decl MIR_UNUSED, } return; } - if (init == NULL) return; + if (init == NULL) { + if (scalar_type_p (type)) error (c2m_ctx, POS (initializer), "empty scalar initializer"); + return; + } assert (init->code == N_INIT); des_list = NL_HEAD (init->u.ops); assert (des_list->code == N_LIST);