This forum has been archived. Please start a new discussion on GitHub.

derived constructor generation bug in slice2cpp

Slice2cpp is generating incorrect code for parameterized constructors of derived classes.

For example, when using the following slice file:
module Test
   class Base
      int a;

   class Derived extends Base
      int b;

slice2cpp generates the following constructor for Derived:
Test::Derived::Derived(::Ice::Int __ice_a, ::Ice::Int __ice_b) :
#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug

Notice that it is passing "a", the yet-to-be-initialized instance variable, to the Base constructor, not "__ice_a", the parameter passed to the Derived constructor. Thus, "a" will wind up being initialized with itself, which is obviously incorrect.

Here's a patch which seems to fix it:
--- src/slice2cpp/Gen.cpp.orig  2006-01-18 20:04:15.000000000 -0600
+++ src/slice2cpp/Gen.cpp       2006-03-01 09:39:48.000000000 -0600
@@ -2397,7 +2397,7 @@
                            upcall += ", ";
-                       upcall += fixKwd((*q)->name());
+                       upcall += "__ice_" + fixKwd((*q)->name());
                    upcall += ")";

Brett Polivka


  • Thanks for the bug report! Your fix looks like it should work. We'll double check it an post an 'official' patch shortly.

    Btw, you should include the name of the project you are using Ice for in your signature. See this posting for details.
  • Thanks for the bug report. I've posted a patch in the patch forum. Please apply this to the 3.0.1 source.

    The fix for this will be included in Ice 3.1, of course.


  • Thank you guys for the amazingly fast turnaround!