slice2cpp generate bad string literals

jbrouaultjbrouault Jean Baptiste RouaultOrganization: diateamProject: none at the moment...Member
I'm using Ice 3.4.1 on linux build with gcc 4.4.3 and linked against the ZeroC patched version of mcpp.

slice2cpp generates bad code for the following slice :
module Foo
{
const string bar = "foo\"quoted\"bar";
};

The generated code is below, the double quotes inside the string aren't escaped anymore:
const ::std::string bar = "foo"quoted"bar";

If in the slice I use bar = "foo\\\"quoted\\\"bar" then slice2cpp generates valid c++ code.

I guess that the function writeConstantValue() in slice2cpp/Gen.cpp should do something similar to Slice::JavaVisitor::writeConstantValue() in the java generator.

Regards,
Jean-Baptiste

Comments

  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi,

    Thanks for reporting this.

    Regards,
    Mark
  • chowchow Brian ChojnowskiOrganization: ATTProject: ACD event publisher 3rd party call control serverMember
    Problem with c++ (vs2010 ultimate) compiling generated floating point literal

    slice file snippet:

    ["clr:property", "clr:class", "cpp:class"] struct RaceXPAdjState {
    RACECLSSKEY key;
    float xpAdj = 1.0;
    };

    produces:


    Ixxon::RaceXPAdjState::RaceXPAdjState() :
    xpAdj(1F)
    {
    }

    which when compiling give the following errors:

    1>Ixxon.cpp(3382): error C2059: syntax error : 'bad suffix on number'
    1>Ixxon.cpp(3382): error C2146: syntax error : missing ')' before identifier 'F'
    1>Ixxon.cpp(3382): error C2612: trailing 'identifier' illegal in base/member initializer list
    1>Ixxon.cpp(3382): error C2059: syntax error : ')'
    1>Ixxon.cpp(3383): error C2065: 'F' : undeclared identifier

    Manually changing (1F) to (1.0F) fixes the problem.
  • chowchow Brian ChojnowskiOrganization: ATTProject: ACD event publisher 3rd party call control serverMember
    Forgot to mention, this is with Ice 3.4.2. I never had a problem with 3.4.1 so I am not sure what it used to generate.
  • bernardbernard Jupiter, FLBernard NormierOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff
    Hi Brian,

    Unfortunately it's a bug that was introduced in 3.4.2. See http://www.zeroc.com/forums/bug-reports/5431-default-vaules-slice.html for a work-around.

    Best regards,
    Bernard
Sign In or Register to comment.