After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622178 - valac emits non-compilable C for nested field initializers
valac emits non-compilable C for nested field initializers
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
unspecified
Other Linux
: Normal major
: 1.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-06-20 11:34 UTC by Martin Olsson
Modified: 2018-02-15 22:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vala: Properly handle array-initializers inside struct-initializers (2.18 KB, patch)
2018-02-15 14:37 UTC, Rico Tzschichholz
none Details | Review
vala: Properly handle array-initializers inside struct-initializers (2.28 KB, patch)
2018-02-15 17:45 UTC, Rico Tzschichholz
none Details | Review
vala: Properly handle array-initializers inside struct-initializers (3.17 KB, patch)
2018-02-15 19:56 UTC, Rico Tzschichholz
committed Details | Review

Description Martin Olsson 2010-06-20 11:34:57 UTC
I'm not entirely sure this is valid Vala but I expect it to yield either an valac error message or compilable C code. Confirmed broken on git master june 20th (5f3df0d).



struct png_chunk
{
	uint32 length;
	uint32 type;
	uchar[] data;
	uint32 crc;
}

void main (string[] args)
{
	png_chunk chunk = {0, 0, {0, 0, 0, 0}, 0};
	if (chunk.length == chunk.type || chunk.crc == 0 || chunk.data == null)
		stdout.printf ("blah\n");
}
Comment 1 Michael 'Mickey' Lauer 2018-02-14 19:56:20 UTC
Thanks for your bug report. This is still an issue with 0.39.7. As with all cases of "acceptable" Vala code leading to invalid C code, we should try to fix this either way or another before 1.0.
Comment 2 Rico Tzschichholz 2018-02-15 14:37:24 UTC
Created attachment 368373 [details] [review]
vala: Properly handle array-initializers inside struct-initializers
Comment 3 Michael 'Mickey' Lauer 2018-02-15 15:46:24 UTC
Review of attachment 368373 [details] [review]:

Awesome. Would have never expected that this could be solved with a one-liner. Thanks!
Comment 4 Rico Tzschichholz 2018-02-15 16:09:11 UTC
Review of attachment 368373 [details] [review]:

This patch causes regressions. So I will look into it further.
Comment 5 Rico Tzschichholz 2018-02-15 17:45:04 UTC
Created attachment 368378 [details] [review]
vala: Properly handle array-initializers inside struct-initializers
Comment 6 Rico Tzschichholz 2018-02-15 19:56:26 UTC
Created attachment 368388 [details] [review]
vala: Properly handle array-initializers inside struct-initializers
Comment 7 Rico Tzschichholz 2018-02-15 22:35:07 UTC
Attachment 368388 [details] pushed as 03395c0 - vala: Properly handle array-initializers inside struct-initializers