This is the mail archive of the
mailing list for the GCC project.
RE: implicit gnat_malloc seen as vararg function
- From: BELBACHIR Selim <selim dot belbachir at fr dot thalesgroup dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 11 Jun 2014 13:41:17 +0200
- Subject: RE: implicit gnat_malloc seen as vararg function
- Authentication-results: sourceware.org; auth=none
- References: <5562_1402399952_5396ECD0_5562_14214_1_9C88BF562A27AA41B242B2780441926E212BE1ADA7 at THSONEA01CMS05P dot one dot grp>
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.