Menu

#1035 gsoap 2.8.24 added virtual dtors to all classes

v1.0 (example)
closed-fixed
None
5
2016-03-24
2016-01-24
No

The following testcase code, built with soapcpp2 -z1 -x test.h:

struct xsd__base64Binary {
        unsigned char *__ptr;
        int __size;
};
struct action {
        unsigned int flags;
        int __union;
        union _act {
                struct _moveCopy {
                        struct xsd__base64Binary store;
                } moveCopy;
                unsigned int bouncecode;
        } act;
};

This was fine with gsoap-2.8.23. Something changed in gsoap-2.8.24 which added a virtual destructor to like everything, and because that makes the structs nontrivial, eventually causes the generated C++ to fail to build now:

$ soapcpp2 -z1 -x test.h
[...]
test.h: *WARNING*: struct '_moveCopy' cannot be assigned a default constructor because it is used as a member of union '_act'
[...]

$ g++ -c soapC.cpp
[...]
soapStub.h: In destructor 'virtual action::~action()':
soapStub.h:98:20: error: use of deleted function '_act::~_act()'
  virtual ~action() { }
                    ^

soapStub.h:77:7: note: '_act::~_act()' is implicitly deleted because the default definition would be ill-formed:
 union _act
       ^~~~

soapStub.h:80:19: error: union member '_act::moveCopy' with non-trivial '_moveCopy::~_moveCopy()'
  struct _moveCopy moveCopy;
                   ^~~~~~~~
[...]

What fixes is needed?

Discussion

  • Robert van Engelen

    The default virtual destructors are removed from structs in version 2.8.28.

     
  • Robert van Engelen

    • status: open --> closed-fixed
    • assigned_to: Robert van Engelen
     
  • Mark Dufour

    Mark Dufour - 2016-03-24

    unfortunately the test code given by jan still doesn't seem to compile, but with a different error:

    The gSOAP code generator for C and C++, soapcpp2 release 2.8.29
    ..
    test.h(17):
    WARNING
    : struct '_moveCopy' cannot be assigned a default constructor because it is used as a member of union '_act'
    ..
    Compilation successful (1 warning)

    root@akeminjo:~# g++ soapC.cpp -lgsoap
    In file included from soapH.h:16:0,
    from soapC.cpp:19:
    soapStub.h:86:26: error: member ‘_moveCopy _act::moveCopy’ with constructor not allowed in union
    struct _moveCopy moveCopy;
    ^
    soapStub.h:86:26: note: unrestricted unions only available with -std=c++11 or -std=gnu++11

     

Log in to post a comment.