Advertisement

Wrong ternary operator usage in scriptstdstring.

Started by July 27, 2011 07:03 AM
1 comment, last by WitchLord 13 years, 4 months ago
I added patch in patches tracker in sourceforge, but since there are only few patches I guess it is almost not used, so I decided to copy text here as well.
Here's link to patch https://sourceforge....752&atid=821100


In add_on/scriptstdstring ternary operator usage is wrong:
//bool b;
stream << b ? "true" : "false";

The '?:' operator has a lower priority than the '<<' operator, so this is equivalent to
(stream << b) ? "true" : "false";
and this is equivalent to
stream << b;
Proper variant is stream << (b ? "true" : "false");
I'm not sure if current version leads to any bugs, but it is definitely wrong. I attached patch, that add braces for ternary operators in scriptstdstring.
Thanks. I'll have this corrected in the SVN.Regards,Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Fix applied in revision 923. Thanks.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement