Menu

#1006 swig tries to call private constructor

None
closed-fixed
5
2023-09-07
2009-04-07
Roblovski
No

In this test case, SWIG will generate a setter for Three::m called _wrap_Three_m_set, which tries to call Two's copy constructor (which is private). If you change "Two m;" to "One m;" SWIG behaves correctly and doesn't generate the setter -- that extra level of inheritance seems to confuse it. Tested with SWIG 1.3.38 & Python.

%module test;

%inline {
struct nocopy
{
nocopy() {}

    private:
        nocopy\(const nocopy&\);
        nocopy& operator=\(const nocopy&\);
\};

struct One: public nocopy \{\};
struct Two: public One \{\};
struct Three \{ Two m; \};

}

Discussion

  • Olly Betts

    Olly Betts - 2022-03-09

    Still reproducible with git master. Here's the testcase without the sourceforge escaping damage:

    %module test;
    
    %inline {
    struct nocopy
    {
    nocopy() {}
    
        private:
            nocopy(const nocopy&);
            nocopy& operator=(const nocopy&);
    };
    
    struct One: public nocopy {};
    struct Two: public One {};
    struct Three { Two m; };
    
    }
    
     
  • William Fulton

    William Fulton - 2023-09-07
    • status: open --> closed-fixed
    • assigned_to: William Fulton
    • Group: -->
     

Log in to post a comment.