Two dimension array access error while release version
Two dimension array access error while release version, please see the code:
Error code and it's screenshot ![Error code]
Vala: 0.46.5 GCC : 9.2.0 Windows: 6.1.7601 Locale: zh-CN
Test code
class ToolActions : GLib.Object {
public const string ACTION_GROUP = "tools";
public const string ACTION_PREFIX = "tools.";
public const string ACTION_DATA_IMPORT = "action_data_import";
public const string ACTION_DATA_EXPORT = "action_data_export";
public const string ACTION_EVENT_HISTORY = "action_event_history";
}
class HelloWorld : GLib.Object {
const string[,] APP_FEATURES = {
{ "Export data", ToolActions.ACTION_DATA_EXPORT, "/kangaroo/data/assets/features/file_export.svg" },
{ "Import data", ToolActions.ACTION_DATA_IMPORT, "/kangaroo/data/assets/features/file_import.svg" },
{ "History logs", ToolActions.ACTION_EVENT_HISTORY, "/kangaroo/data/assets/features/log_events.svg" }
};
public HelloWorld()
{
this.array_handler();
}
private void array_handler()
{
// debug version ok, release version failed
for(int index = 0; index < APP_FEATURES.length[0]; index++) {
stdout.printf("for statement: %s %s %s\n", APP_FEATURES[index, 0], APP_FEATURES[index, 1], APP_FEATURES[index, 2]);
}
// every thing ok
stdout.printf("direct access: %s %s %s\n", APP_FEATURES[0, 0], APP_FEATURES[0, 1], APP_FEATURES[0, 2]);
stdout.printf("direct access: %s %s %s\n", APP_FEATURES[1, 0], APP_FEATURES[1, 1], APP_FEATURES[1, 2]);
stdout.printf("direct access: %s %s %s\n", APP_FEATURES[2, 0], APP_FEATURES[2, 1], APP_FEATURES[2, 2]);
}
public static int main(string[] args)
{
HelloWorld hello_world = new HelloWorld();
stdout.printf("%s\n", hello_world.get_type().name());
return 0;
}
}
project(
'vala_array',
['c', 'vala'],
meson_version: '>= 0.40.0',
)
sources_common = [
'vala_array.vala',
]
deps_common = [
dependency('gio-2.0', version: '>= 2.58'),
]
executable(meson.project_name(), sources_common, dependencies: deps_common)
run command, then output as follow:
meson --buildtype=release build
-------->
for statement: Export data action_data_export /kangaroo/data/assets/features/file_export.svg
for statement: Import data action_data_import /kangaroo/data/assets/features/file_export.svg
for statement: History logs action_event_history /kangaroo/data/assets/features/file_export.svg
direct access: Export data action_data_export /kangaroo/data/assets/features/file_export.svg
direct access: Import data action_data_import /kangaroo/data/assets/features/file_import.svg
direct access: History logs action_event_history /kangaroo/data/assets/features/log_events.svg
HelloWorld
Edited by TAO ZUHONG