Skip to main content
GameDev.net gamedev.net
🔒 Locked

Wrong ternary operator usage in scriptstdstring.

Started by Altren Jul 27, 2011 at 7:03 AM 1 replies 1.4k views
Original Post
Altren
Altren
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.
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.