Kröhnert, Manfred <manfred.kroehn...@kit.edu> wrote on 02/08/2011 02:49:01 
PM:

> Hello everyone,
> 
> I have a problem with the attached test program.
> 
> It declares a class 'Base' and two other classes 'B' and 'C' which 
> extend 'Base'.
> On each class a method 'asC(): C' is implemented which returns an 
> instance of Class 'C'.
> The class 'Base' contains a static cast operator which invokes 'asC()'
> on the given object.
> 
> Afterwards instances of 'B' and 'C' are created in two different ways 
> and the objects are then cast to type 'C'  by invoking the 'as C' 
> operator and by calling the 'asC()' method.
> 
> I would expect the program to behave the same in all occasions but it 
> aborts with a ClassCastException and produces the following output:
> 
> b: 15
> b as C: 42
> Uncaught exception at place 0: x10.lang.MultipleExceptions: null
> c: 51
> x10.lang.ClassCastException: null
> c as C: 51
> 
> b2: 15
> b2 as C: 42
> c2: 51
> c2 as C: 51
> 
> b3: 15
>    at x10::lang::Throwable::fillInStackTrace()
>    at x10aux::throwClassCastException()
>    at x10aux::ref<C> x10aux::real_class_cast<C>(x10aux::ref<x10::
> lang::Reference>, bool)
>    at x10aux::ClassCastNotPrimitive<x10aux::ref<C>, x10aux::ref<Base> 
> >::_(x10aux::ref<Base>, bool)
>    at x10aux::ClassCastPrimitive<x10aux::ref<C>, x10aux::ref<Base> >::
> _(x10aux::ref<Base>, bool)
>    at x10aux::ClassCast<x10aux::ref<C>, x10aux::ref<Base> >::
> _(x10aux::ref<Base>, bool)
>    at x10aux::ref<C> x10aux::class_cast<x10aux::ref<C>, x10aux::
> ref<Base> >(x10aux::ref<Base>)
>    at Hello::main(x10aux::ref<x10::array::Array<x10aux::ref<x10::
> lang::String> > >)
>    at x10aux::BootStrapClosure::apply()
>    at x10_lang_Runtime__closure__2::apply()
>    at x10::lang::Activity::run()
>    at x10::lang::Runtime__Worker::loop(x10aux::ref<x10::lang::
> SimpleLatch>, bool)
>    at x10::lang::Runtime__Worker::apply()
>    at x10::lang::Runtime__Pool::apply()
>    at x10::lang::Runtime::start(x10aux::ref<x10::lang::VoidFun_0_0>, 
> x10aux::ref<x10::lang::VoidFun_0_0>)
>    at int x10aux::template_main<x10::lang::Runtime, Hello>(int, char**)
>    at main
>    at start
> 
> Is this a bug in the compiler or in the runtime or is it expected 
behaviour?
> I am using the C++ backend with X10DT 2.1.1 on OS X 10.6.6 (Intel).

Manfred,

This list strips attachments.  If the program is small enough, please
include it verbatim.  Otherwise, please either open a JIRA (if you believe
that this disagrees with the language specification) or try to reduce this
to a small test case that can be posted verbatim.

Thanks,
        Igor
-- 
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" -- 
Xun Zi


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to