On 29/03/2012, at 7:56 PM, Jean-Noël Monette wrote:
> Hello,
>
> Here is a new problem I came across with NaryUnion. As suggested by
> Christian, I created a fresh region for every new NaryUnion, however I ran
> into an infinite loop. Below is a minimal example. I located the infinite
> loop inside the "two(I& i, J& j)" method of NaryUnion, and the reason seems
> to be that, after the call to "RangeList* t = range(j)" in the "else if"
> block (I unfortunately cannot give you line numbers as I messed around with
> print statements), "i.c" and "t" point to the very same RangeList (while they
> should not). I'm not expert enough to go deeper/further...
>
> Notice that this appears only when region2 is created in a block (in real
> code, it would be inside a "for" or a "if"), however there is no influence if
> it is actually used or not.
>
> I guess it is again related to the Region implementation that is going to
> change, but I think it is worth mentioning it anyway.
Memory allocated from a region only lives as long as the region, and by passing
u0 out of its region's scope, you get a dangling pointer. It's like writing
char* c;
{ string s = "hello"; c = s.c_str(); }
string s = "world";
printf("%s",c);
which will probably print world rather than hello. So I'd say this is a bug in
your code (and we should improve the documentation to make this clear).
Cheers,
Guido
_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users