[great-users] Small bug - SetStrValue is not checked...
Tivadar Szemethy
tiv at isis.vanderbilt.edu
Wed Apr 7 14:45:05 CDT 2004
> I'm using the officially unreleased version of GReAT. I was not
careful
> enough and tried the following thing in an attribute mapping:
>
> <something>.SetStrVale("something", 0);
>
> Obviously it should be:
>
> <something>.SetStrVale("something", "0");
>
> No errors are reported during configuration and the execution of this
> rule crashes GME.
This is kind of strange. SetStrValue has signature
bool SetStrValue(string strAttrName, const string& value);
and the compiler MUST NOT accept an integer zero for &value, since 0 cannot be
cast into a string reference.
Even if it was not a zero, you should get some kind of error unless you
cast explicitly, and even so you have to figure out a trikcy cast to outwit the compiler.
If I try something similar, I get the expected error:
Gz__SMOLES2UPPAAL-gr.cpp(37) : error C2664: 'GetStrValue' : cannot convert parameter 2 from 'const int' to 'class _STL::basic_string<char,struct std::char_traits<char>,class _STL::allocator<char> > &'
A reference that is not to 'const' cannot be bound to a non-lvalue
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
>[Adi]
>The AttributeMapping and Guard code is compiled into a dll by GRE and
>called at run time. Since the code you wrote is valid C++ code it is
>successfully compiled and linked. In your case it's a semantic error
>that even the C++ compiler cannot catch.
I disagree, see above.
Tivadar
More information about the great-users
mailing list