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 540730 - Compiler accepts invalid array creation expressions for stacked arrays
Compiler accepts invalid array creation expressions for stacked arrays
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Arrays
0.3.x
Other All
: Low minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-06-29 09:36 UTC by Sebastian Pölsterl
Modified: 2010-03-20 16:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (242 bytes, text/plain)
2008-06-29 09:37 UTC, Sebastian Pölsterl
Details

Description Sebastian Pölsterl 2008-06-29 09:36:48 UTC
The code compiles, but running it causes a segfault.
Comment 1 Sebastian Pölsterl 2008-06-29 09:37:06 UTC
Created attachment 113596 [details]
Test case
Comment 2 Amos Brocco 2008-07-22 10:28:10 UTC
The following code:

	MyClass[,] matrix2o = new MyClass[10,10];
	
Produces the following:

	_tmp6 = NULL;
	matrix2o = (_tmp6 = g_new0 (MyClass*, 10 + 1 * 10 + 1), matrix2o_length1 = 10, matrix2o_length2 = 10, _tmp6);

In fact, because of missing brackets, the allocated size of just 21 instead of 10*10 = 100. Also, I don't understand the + 1, shouldn't MyClass[10,10] define an array of 100 elements ?



Comment 3 Jürg Billeter 2008-07-22 11:23:00 UTC
Sebastian, that's actually invalid code. The array in your test case is a stacked/jagged array, not a two-dimensional array. The example from Amos shows how a two-dimensional array should look like.

I'm changing the bug summary to reflect the missing validation of the array creation expression.
Comment 4 Jürg Billeter 2008-07-22 11:24:39 UTC
Amos, that's a different issue, can you please open a separate bug for this?
Comment 5 Jürg Billeter 2010-03-20 16:42:49 UTC
commit cb808bc94d7e0c2045af52595d5d358b102ce32e
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Mar 20 17:42:00 2010 +0100

    Report error on invalid array creation expressions for stacked arrays
    
    Fixes bug 540730.