Skip to content

Problem parsing castxml output of template function default argument of template type #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lordylike opened this issue Jun 9, 2017 · 2 comments

Comments

@lordylike
Copy link

lordylike commented Jun 9, 2017

I've recently started migrating from gccxml to castxml and have encountered the aforementioned problem.
I could narrow the problem down to a minimum example that still fails:

template<typename Type>
class TemplateClass
{
public:
	void func(Type val = (Type)0.0)
 	{
	}
};
template class TemplateClass<float>;

Called with following cmd line arguments:
-std=c++14 -c -x c++ --castxml-cc-msvc "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe" --castxml-gccxml -o "test.xml" "test.h"

Produces an xml with following argument tag:

<Method id="_8" name="func" returns="_14" context="_5" access="public" location="f1:7" file="f1" line="7" inline="1" mangled="?func@?$TemplateClass@MN@@QAEXMN@Z" attributes="__thiscall__">
    <Argument name="val" type="_15" location="f1:7" file="f1" line="7" default="(type-parameter-0-0)0."/>
</Method>

The information referring to the (Type)0.0 default argument given can be found within the (type-parameter-0-0) information found in the Argument tag default coupled with the Class referenced in the Method's context information, which states:

<Class id="_5" name="TemplateClass&lt;float&gt;" context="_1" location="f1:13" file="f1" line="13" members="_8 _9 _10 _11 _12" size="8" align="8"/>

From these two places, I would expect gccxml to figure out that the default argument should be written as (float)0.. Instead it parses this to (type-parameter-0-0)0..

@iMichka
Copy link
Collaborator

iMichka commented Jun 15, 2017

Hi. Thanks for letting me know. I'll try to have a look at this during the weekend.

@RomanYakovenko
Copy link

In the past (gccxml) default arguments was dump almost as "just a text". "Default argument" can contain arbitrary complex C++ expression evaluated at run time. Dumping such expression was out of scope of gccxml and of pygccxml. You were lucky in this case. I was less lucky in other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants