Home Bug Reports

derived constructor generation bug in slice2cpp

bpolivkabpolivka Member Brett PolivkaOrganization: Magnetar CapitalProject: Financial Core Services
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
    Base(a),
#else
    ::Test::Base(a),
#endif
    b(__ice_b)
{
}

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 += ")";
                }

Thanks,
Brett Polivka

Comments

  • beaglesbeagles Member Brent EaglesOrganization: Eagles Technologies IncProject: Asterisk SCF ✭✭✭
    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.
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.

    Cheers,

    Michi.
  • bpolivkabpolivka Member Brett PolivkaOrganization: Magnetar CapitalProject: Financial Core Services
    Thank you guys for the amazingly fast turnaround!
Sign In or Register to comment.