#1178 upcast bug with shared_ptr

None
closed
5
2016-06-21
2011-06-26
Anonymous
No

Polymorphism for shared_ptr declared templated classes which use typedef does not work.
If a templated shared_ptr class hiearchy is declared which uses a typedef for the templated class, SWIG does not correctly resolve the correct class hierchy.

This is illustrated by the minimal example attached, which fails when run. I am not sure it is related but in the generated wrapper code are shared_ptr types generated correctly for the typedefed template class Base<INT> and Derived<INT>

#define SWIGTYPE_p_boost__shared_ptrT_BaseT_INT_t_t swig_types[2]
#define SWIGTYPE_p_boost__shared_ptrT_DerivedT_INT_t_t swig_types[3]

But only the corresponding none shared_ptr type is defined with the typedef resolved:

#define SWIGTYPE_p_boost__shared_ptrT_BaseT_INT_t_t swig_types[2]
#define SWIGTYPE_p_boost__shared_ptrT_DerivedT_INT_t_t swig_types[3]

Johan

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-26
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-26
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-26
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-26

    The handed test has been checked failing for SWIG version 2.0.4 on a Linux box

    The bug can be reproduced by downloading the files and type

    make

    Johan

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-26

    The last two #defines in the description should be

    #define SWIGTYPE_p_BaseT_int_t swig_types[0]
    #define SWIGTYPE_p_DerivedT_int_t swig_types[1]

    Note the *int* instead of *INT*

    Johan

     
  • William Fulton

    William Fulton - 2011-06-30

    In cplus_inherit_types_impl() in typepass.cxx,
    smart = SwigType_typedef_resolve_all(spt);
    is failing to resolve spt == "boost::shared_ptr<(Derived<(INTT)>)>"

     
  • William Fulton

    William Fulton - 2011-08-13

    You can move the typedef to above the %shared_ptr statements so that the type information is fully available. However, I've fixed your example for swig-2.0.5 so that it works as you'd hope it to.

     
  • William Fulton

    William Fulton - 2011-08-13
    • assigned_to: nobody --> wsfulton
    • labels: 102864 --> code generation (general)
    • status: open --> closed-fixed
     
  • William Fulton

    William Fulton - 2012-04-14

    The fix has been reverted for swig-2.0.5 (svn revision 12953) as it introduces other %shared_ptr regressions. To be looked at later...

     
  • William Fulton

    William Fulton - 2012-04-14
    • status: closed-fixed --> open
     
  • William Fulton

    William Fulton - 2012-04-14

    Also note rev 12982 when coming back to this bug.

     
  • William Fulton

    William Fulton - 2016-06-21
    • status: open --> closed
    • Group: -->
     
  • William Fulton

    William Fulton - 2016-06-21

    This particular case has been fixed for swig-3.0.11.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks