Hi, fixed in the trunk, patch is attached. Christian
--
Christian Schulte, www.ict.kth.se/~cschulte/
From: [email protected] [mailto:[email protected]] On Behalf
Of Farshid Hassani Bijarbooneh
Sent: Thursday, July 11, 2013 6:01 PM
To: [email protected]
Subject: [gecode-users] operator = for NaryUnion
Hi,
In Gecode 4.1 creating n-ary union of variable ranges and assigning to a
NaryUnion causes a segmentation fault, whereas in Gecode 3.7.3 it seems to
work:
Region myRegion(*this);
Iter::Ranges::NaryUnion narr[2];
IntVarRanges* varRange = myRegion.alloc<IntVarRanges>(x.size()); // x is
IntVarArray variables of the model
for (int r=0; r < x.size(); r++) {
varRange[r].init(x[r]);
}
narr[0] = Iter::Ranges::NaryUnion(myRegion, varRange, x.size());
If we instead create only one NaryUnion then it works fine in Gecode 4.1:
Iter::Ranges::NaryUnion uni(myRegion, varRange, x.size());
I also attached a minimal code demonstrating this issue. Do you think if
there is something I'm missing here?
Cheers,
Farshid
_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users
Index: gecode/iter/ranges-list.hpp
===================================================================
--- gecode/iter/ranges-list.hpp (revision 13860)
+++ gecode/iter/ranges-list.hpp (working copy)
@@ -130,12 +130,11 @@
forceinline
RangeListIter::RangeListIter(void)
- : rlio(NULL) {}
+ : rlio(NULL), h(NULL), c(NULL) {}
forceinline
RangeListIter::RangeListIter(Region& r)
- : rlio(new (r.ralloc(sizeof(RLIO))) RLIO(r)),
- h(NULL), c(NULL) {}
+ : rlio(new (r.ralloc(sizeof(RLIO))) RLIO(r)), h(NULL), c(NULL) {}
forceinline void
RangeListIter::init(Region& r) {
@@ -146,19 +145,21 @@
forceinline
RangeListIter::RangeListIter(const RangeListIter& i)
: rlio(i.rlio), h(i.h), c(i.c) {
- rlio->use_cnt++;
+ if (rlio != NULL)
+ rlio->use_cnt++;
}
forceinline RangeListIter&
RangeListIter::operator =(const RangeListIter& i) {
if (&i != this) {
- if (--rlio->use_cnt == 0) {
+ if ((rlio != NULL) && (--rlio->use_cnt == 0)) {
Region& r = rlio->allocator();
rlio->~RLIO();
r.rfree(rlio,sizeof(RLIO));
}
rlio = i.rlio;
- rlio->use_cnt++;
+ if (rlio != NULL)
+ rlio->use_cnt++;
c=i.c; h=i.h;
}
return *this;
@@ -166,7 +167,7 @@
forceinline
RangeListIter::~RangeListIter(void) {
- if (--rlio->use_cnt == 0) {
+ if ((rlio != NULL) && (--rlio->use_cnt == 0)) {
Region& r = rlio->allocator();
rlio->~RLIO();
r.rfree(rlio,sizeof(RLIO));
Index: gecode/iter/ranges-union.hpp
===================================================================
--- gecode/iter/ranges-union.hpp (revision 13860)
+++ gecode/iter/ranges-union.hpp (working copy)
@@ -276,7 +276,8 @@
forceinline
- NaryUnion::NaryUnion(void) {}
+ NaryUnion::NaryUnion(void)
+ : f(NULL) {}
template<class I>
forceinline void
_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users