#40 string comparison operators are not commutative

closed-fixed
library (36)
5
2004-05-17
2004-03-31
No

Gary reported that

if (mystring == "test") ...

and

if ("test" == mystring)

do not return the same result. The reason is that not all
combinations of comparison operators are actually
defined in the string class. As a result, the compiler puts
a simple pointer comparison for the second statement
above, and the result is, in fact, always false.

Discussion

  • Hovik Melikyan

    Hovik Melikyan - 2004-05-17
    • status: open --> closed-fixed
     
  • Hovik Melikyan

    Hovik Melikyan - 2004-05-17

    Logged In: YES
    user_id=564494

    Fixed in the latest release.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks