Archived
This forum has been archived. Please start a new discussion on GitHub.
default vaules in Slice
in Bug Reports
Hi Guys,
Testing my code with Ice 3.4.2 and noticed a change in generated code with regards to initializer lists in C++.
It's to do with float default values.
Example SLICE
class aClass
{
float a = 0.0;
float b = 1.1;
double c = 0.0;
double d = 1.1;
};
This used to generate
::aClass::aClass() :
a(0),
b(1.1),
c(0),
d(1.1)
Now it generates
::aClass::aClass() :
a(0F),
b(1.1F),
c(0),
d(1.1)
GCC and Visual Studio is now complaining about variable 'a' with an invalid suffix 'F'.
Having 'F' is more correct, however the parser should not be truncating default values for floats and doubles.
(float a = 0F) != (float a = 0.0F)
My only work around is not to set a default value of 0.0 anymore. Or hack the cpp/src/slice2cpp/Gen.cpp line 107 and remove the 'F' suffix.
VERY annoying..!
cheers
Denn
Testing my code with Ice 3.4.2 and noticed a change in generated code with regards to initializer lists in C++.
It's to do with float default values.
Example SLICE
class aClass
{
float a = 0.0;
float b = 1.1;
double c = 0.0;
double d = 1.1;
};
This used to generate
::aClass::aClass() :
a(0),
b(1.1),
c(0),
d(1.1)
Now it generates
::aClass::aClass() :
a(0F),
b(1.1F),
c(0),
d(1.1)
GCC and Visual Studio is now complaining about variable 'a' with an invalid suffix 'F'.
Having 'F' is more correct, however the parser should not be truncating default values for floats and doubles.
(float a = 0F) != (float a = 0.0F)
My only work around is not to set a default value of 0.0 anymore. Or hack the cpp/src/slice2cpp/Gen.cpp line 107 and remove the 'F' suffix.
VERY annoying..!
cheers
Denn
0
Comments
-
Hi Deen
as a workaround you can use a const int:const int zeroI = 0; struct s { float x = zeroI; }
Thanks for report the bug, we will fix this in the next Ice release0