History

tccgen.c: Fix flex array members some more

Last fix didn't work for function f1int in the added testcase.

Michael Matz committed 10 years ago

Commit ceccd3e1 parent 7e0ad4f3 files · +31 −2Browse files

Showing the changes to tccgen.c (1 of 3 files). Show all

Unified · Split

tccgen.c+6−2
@@ -5846,8 +5846,12 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 5845 unmodified lines
58465846 if (size < 0)
58475847 tcc_error("unknown type size");
58485848 }
5849− if (flexible_array)
5850− size += flexible_array->type.ref->c * pointed_size(&flexible_array->type) + 1;
5849+ /* If there's a flex member and it was used in the initializer
5850+ adjust size. */
5851+ if (flexible_array &&
5852+ flexible_array->type.ref->c > 0)
5853+ size += flexible_array->type.ref->c
5854+ * pointed_size(&flexible_array->type);
58515855 /* take into account specified alignment if bigger */
58525856 if (ad->a.aligned) {
58535857 if (ad->a.aligned > align)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t