Menu

#21 C++ generator : virtual destructor should be "{}" not "= 0"

None
closed
nobody
None
1
2014-07-06
2014-05-30
No

because "= 0" create “undefined reference” when using a class as interface with virtual destructor.
Please read http://stackoverflow.com/questions/2555033 for example. This guy had the same problem I have.

1 Attachments

Discussion

  • Oliver Kellogg

    Oliver Kellogg - 2014-05-30
    • status: open --> accepted
    • Group: -->
     
  • Oliver Kellogg

    Oliver Kellogg - 2014-05-30

    Thanks for providing this patch. I applied it on git master in commit 218790d

     
  • LE GARREC Vincent

    Thanks for applying all the patches. I'm not absolutly sure this one will not create bad shadow effect (for exemple if someone want to define a virtual destrutor) but history will say. Other patches will come and I just open 2 threads on discussion because I have 2 problems that can not remove easily.

     
  • LE GARREC Vincent

    As I said, "history will say". I'm sorry, I think this idea is bad. With the example enclosed, the behavious is different with or without the virtual destructor. So if destructor is "virtual ~aaa () {};" I can't define the following destructor :

    aaa::aaa ()
    {
    std::cout << "début\n";
    }

    but with "virtual ~aaa () = 0;", it's okay.

    Don't you thing that we should reverse this commit (or changing the patch to disabling the "{}" or "= 0" for the destructor) ? And to avoid the bug, the user will have to write an empty method for the destructor.

     

    Last edit: LE GARREC Vincent 2014-06-22
  • LE GARREC Vincent

    Proposal patch for this bug.

     
  • Oliver Kellogg

    Oliver Kellogg - 2014-07-06
    • status: accepted --> closed
     
  • Oliver Kellogg

    Oliver Kellogg - 2014-07-06

    Thanks for providing the new patch. I applied it on git master in commit a54728.

     

Log in to post a comment.