implicit gnat_malloc seen as vararg function
BELBACHIR Selim
selim.belbachir@fr.thalesgroup.com
Wed Jun 11 11:41:00 GMT 2014
Hi,
I have more info concerning my gnat_malloc problem.
I watched the code in gcc/ada/gcc-interface/trans.c and found the location where malloc_decl tree is built.
In gigi ()function (trans.c:411), the ftype for malloc_decl is done this way :
ftype = build_function_type_list (ptr_void_type_node, sizetype, NULL_TREE);
I looked at the code of build_function_type_list_1 in tree.c and found that stdargs function are built with their chained list of argument ending with a void_list_node :
{
last = args;
args = nreverse (args);
TREE_CHAIN (last) = void_list_node;
}
But I also noticed that void_list_node was a null pointer!! instead of being a node with TREE_VALUE = void_type_node and no TREE_CHAIN (as described in tree.h)
So I wondered, where should void_list_node be initialized in GNAT frontend and noticed that the initialization of void_list_node was done AFTER its use to declare ftype for malloc_decl.
ftype for malloc_decl is initialized in gigi() function at trans.c:411 whereas void_list_node in only initialized in gigi() function at trans.c:665 by a call to gnat_install_builtins() ---> install_builtin_elementary_types() --> void_list_node = build_void_list_node ();
It seems like a bug. Is it a known one ? someone has the proper fix ? I put the call to gnat_install_builtins() higher inside gigi() and it solve my current problem but I'm not sure exactly when it has to be called and if there are bad side effects.
Regards,
Selim Belbachir
More information about the Gcc
mailing list