MantisBT - GCC-XML
View Issue Details
0010367GCC-XMLpublic2010-03-04 09:432015-03-26 11:59
axel 
Brad King 
normalminoralways
resolvedsuspended 
0010367: templated c'tor gets instantiated as copy c'tor
According to 12.8.3 ("A member function template is never instantiated to perform the copy of a class object to an object of its class type"), the following code should not instantiate the templated constructor as a copy constructor. It should not be visible in GCCXML's output, just like h() is not visible.

With a recent GCCXML snapshot I see
  <Constructor id="_161" name="S" context="_137" access="public" mangled="_ZN1SC1IS_EET_ *INTERNAL* " demangled="S::S<S>(S)" location="f1:3" file="f1" line="3" extern="1">

Is that difficult to fix?

struct S {
   template <typename T> S(T);
   template <typename T> void h(T);
};
S f();
void g() {
   S a( f() ); // does not instantiate member template
}
No tags attached.
Issue History
2010-03-04 09:43axelNew Issue
2010-03-04 11:34Brad KingStatusnew => assigned
2010-03-04 11:34Brad KingAssigned To => Brad King
2010-03-04 11:36Brad KingNote Added: 0019708
2010-03-05 04:24axelNote Added: 0019723
2010-03-05 08:10Brad KingNote Added: 0019726
2015-03-26 11:59Brad KingNote Added: 0038327
2015-03-26 11:59Brad KingStatusassigned => resolved
2015-03-26 11:59Brad KingResolutionopen => suspended

Notes
(0019708)
Brad King   
2010-03-04 11:36   
If I change the example to

struct S {
        template <typename T> S(T) { T().blah(); }
        template <typename T> void h(T);
};
S f();
void g() {
        S a( f() ); // does not instantiate member template
        S b(static_cast<S*>(0)); // error
}

then I get an error at b() but not at a().

The GCC 4.2 parser that gcc-xml uses internally must be instantiating the interface long enough to figure out that it shouldn't use it, and then skip instantiating the body. However by that point it is too late to stop xml.c from seeing the instantiated declaration.

I have no time to investigate this now. If you want to try I can get you started.
(0019723)
axel   
2010-03-05 04:24   
Hi Brad,

yes, can you send me a pointer what I should be looking at to work around this issue? I suppose I would simply explicitly suppress all copy constructor member templates.

Cheers, Axel.
(0019726)
Brad King   
2010-03-05 08:10   
Look for the "xml_add_template_decl" function in "GCC/gcc/cp/xml.c" with in the source.
(0038327)
Brad King   
2015-03-26 11:59   
As announced here:

 [ANNOUNCE] GCC-XML maintenance moving to Github
 http://thread.gmane.org/gmane.comp.compilers.gccxml/731 [^]
 http://public.kitware.com/pipermail/gccxml/2015-March/003206.html [^]

gccxml will no longer be developed by its original author, who will instead focus on CastXML:

 https://github.com/CastXML/CastXML#readme [^]

The original GCC-XML issue tracker is now closed. In order to facilitate ongoing maintenance by community participants, issues will now be tracked on the Github repository page:

 https://github.com/gccxml/gccxml/issues [^]