Han, This indeed looks like a bug in the C++ implementation of String.compareTo(). Please open a JIRA and we'll fix this. Thanks for the report. Igor
Han Dong <saviola7...@gmail.com> wrote on 07/01/2010 09:38:43 PM: > Hi, > > Sorry for the late response and thanks for helping me. > > The generated C++ code is as follows: > > #include <Test.h> > > > #include "Test.inc" > > void Test::_instance_init() { > _I_("Doing initialisation for class: Test"); > > } > > > //#line 8 "/home/han6/Test.x10": x10.ast.X10MethodDecl_c > #include <x10/lang/Runtime.h> > #include <x10aux/bootstrap.h> > extern "C" { int main(int ac, char **av) { return > x10aux::template_main<x10::lang::Runtime,Test>(ac,av); } } > > void Test::main(x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > > args) { > > //#line 11 "/home/han6/Test.x10": x10.ast.X10LocalDecl_c > x10aux::ref<x10::lang::String> s1 = x10::lang::String::Lit("aaaa"); > > //#line 12 "/home/han6/Test.x10": x10.ast.X10LocalDecl_c > x10aux::ref<x10::lang::String> s2 = x10::lang::String::Lit("zz"); > > //#line 14 "/home/han6/Test.x10": polyglot.ast.Eval_c > > x10aux::nullCheck(x10::io::Console::FMGL(OUT__get)())->x10::io:: > Printer::println( > x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> > >(((s1)->compareTo(s2) <= 0))); > > //#line 15 "/home/han6/Test.x10": polyglot.ast.Eval_c > > x10aux::nullCheck(x10::io::Console::FMGL(OUT__get)())->x10::io:: > Printer::println( > x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> > >((s1)->compareTo(s2))); > } > > //#line 7 "/home/han6/Test.x10": x10.ast.X10ConstructorDecl_c > void Test::_constructor() { > this->x10::lang::Object::_constructor(); > > } > x10aux::ref<Test> Test::_make() { > x10aux::ref<Test> this_ = new (x10aux::alloc<Test>()) Test(); > this_->_constructor(); > return this_; > } > > > const x10aux::serialization_id_t Test::_serialization_id = > > x10aux::DeserializationDispatcher::addDeserializer(Test:: > _deserializer<x10::lang::Object>); > > void Test::_serialize_body(x10aux::serialization_buffer& buf) { > x10::lang::Object::_serialize_body(buf); > > } > > void Test::_deserialize_body(x10aux::deserialization_buffer& buf) { > x10::lang::Object::_deserialize_body(buf); > > } > > x10aux::RuntimeType Test::rtt; > void Test::_initRTT() { > if (rtt.initStageOne(&rtt)) return; > const x10aux::RuntimeType* parents[1] = { > x10aux::getRTT<x10::lang::Object>()}; > rtt.initStageTwo("Test", 1, parents, 0, NULL, NULL); > } > > > Thanks, > > Han Dong > h...@umbc.edu > University of Maryland '10 > > On Wed, Jun 23, 2010 at 7:46 PM, Yoav Zibin <yoav.zi...@gmail.com> wrote: > > > Please email the generated C++ code, > > e.g., > > > > > > //#line 197 "C:\cygwin\home\Yoav\test\Hello.x10": x10.ast.X10LocalDecl_c > > x10aux::ref<x10::lang::String> s1 = x10::lang::String::Lit("aaaa"); > > > > //#line 198 "C:\cygwin\home\Yoav\test\Hello.x10": x10.ast.X10LocalDecl_c > > x10aux::ref<x10::lang::String> s2 = x10::lang::String::Lit("zz"); > > > > //#line 200 "C:\cygwin\home\Yoav\test\Hello.x10": polyglot.ast.Eval_c > > > > > > x10aux::nullCheck(x10::io::Console::FMGL(OUT__get)())->x10::io:: > Printer::println( > > x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> > > >(((s1)->compareTo(s2) <= 0))); > > > > //#line 201 "C:\cygwin\home\Yoav\test\Hello.x10": polyglot.ast.Eval_c > > > > > > x10aux::nullCheck(x10::io::Console::FMGL(OUT__get)())->x10::io:: > Printer::println( > > x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> > > >((s1)->compareTo(s2))); > > > > > > > > > On Wed, Jun 23, 2010 at 7:26 PM, Han Dong <saviola7...@gmail.com> wrote: > > > > > This is the code i'm running: > > > > > > import x10.io.Console; > > > import x10.io.*; > > > import x10.lang.*; > > > import x10.util.*; > > > > > > public class Test > > > { > > > public static def main(args:Rail[String]) > > > { > > > var s1:String = "aaaa"; > > > var s2:String = "zz"; > > > > > > Console.OUT.println((s1 <= s2)); > > > Console.OUT.println(s1.compareTo(s2)); > > > } > > > } > > > > > > Seems the system has an issue with compiling Java backend, so I was not > > > able > > > to test it on that. What version of x10 are you running? If your code > > gives > > > back the correct answer, then it probably could be issues with the x10 on > > > the system. > > > > > > Thanks, > > > > > > Han Dong > > > h...@umbc.edu > > > University of Maryland '10 > > > > > > On Wed, Jun 23, 2010 at 6:34 PM, Yoav Zibin <yoav.zi...@gmail.com> > > wrote: > > > > > > > according to the output (false and -2) then you're probably using these > > > > strings: > > > > > > > > var s1:String = "aaaa"; > > > > var s2:String = "aa"; > > > > > > > > and not: > > > > var s1:String = "aaaa"; > > > > var s2:String = "zz"; > > > > > > > > please double check. > > > > > > > > > > > > On Wed, Jun 23, 2010 at 6:29 PM, Yoav Zibin <yoav.zi...@gmail.com> > > > wrote: > > > > > > > > > It works for me both in Java and in C++. > > > > > Can you send your test file? > > > > > > > > > > > > > > > y...@yoavlaptop ~/test > > > > > $ x10c Hello.x10 > > > > > > > > > > y...@yoavlaptop ~/test > > > > > $ x10 Hello > > > > > true > > > > > -25 > > > > > > > > > > y...@yoavlaptop ~/test > > > > > $ x10c++ Hello.x10 > > > > > > > > > > y...@yoavlaptop ~/test > > > > > $ x10 Hello > > > > > true > > > > > -25 > > > > > > > > > > > > > > > > > > > > > > > > > On Wed, Jun 23, 2010 at 5:39 PM, Han Dong <saviola7...@gmail.com> > > > wrote: > > > > > > > > > >> Hi all, > > > > >> > > > > >> I have a question regarding the String compareTo function and the > > "<=" > > > > >> function in x10. I have this test code: > > > > >> > > > > >> var s1:String = "aaaa"; > > > > >> var s2:String = "zz"; > > > > >> > > > > >> Console.OUT.println((s1 <= s2)); > > > > >> Console.OUT.println(s1.compareTo(s2)); > > > > >> > > > > >> which gave me these outputs: > > > > >> > > > > >> : false > > > > >> : 2 > > > > >> > > > > >> For the first comparison test utilizing the "<=" function, it states > > > in > > > > >> the > > > > >> API that it compares if the first string is before the second string > > > in > > > > >> dictionary order, however the output is 'false' which means "aaaa" > > is > > > > not > > > > >> before "zz"? > > > > >> > > > > >> For the second comparison test utilizing the "compareTo" function, > > > since > > > > >> it > > > > >> gave an output of positive 2, this means that s1 follows s2. > > However, > > > in > > > > >> my > > > > >> past experiences with compareTo functions, it should be giving me a > > > > >> negative > > > > >> integer since "aaaa" should be before "zz"? > > > > >> > > > > >> I am running this code on my school's intel nehalem blades, it has > > > > >> x10-2.0.3 > > > > >> on them. Compiling, i use: > > > > >> > > > > >> x10-2.0.3/bin/x10c++ test.x10 > > > > >> mpiexec -n 1 ./a.out > > > > >> > > > > >> > > > > >> Thanks, > > > > >> > > > > >> Han Dong > > > > >> h...@umbc.edu > > > > >> University of Maryland '10 -- Igor Peshansky (note the spelling change!) IBM T.J. Watson Research Center X10: Parallel Productivity and Performance (http://x10-lang.org/) XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/) "I hear and I forget. I see and I remember. I do and I understand" -- Confucius ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users