Voici une petite erreur que je viens d'avoir, et dont je voudrais avoir vos avis...
Affichage gdb :
Code source du fichier lin-expr.cc
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x09b608d6 0x022a0134 in Gecode::MiniModel::LinExpr::post (this=0xbfffe41c, home=0x397a0a0, icl=ICL_DEF) at gecode/minimodel/lin-expr.cc:81 81 min += ts[i].a*ts[i].x.min(); (gdb) print i $3 = 3 (gdb) print n $4 = 2
Petites explications :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 00073 IntVar 00074 LinExpr::post(Space* home, IntConLevel icl) const { 00075 GECODE_AUTOARRAY(Int::Linear::Term, ts, n+1); 00076 (void) ax->fill(ts,0,sign); 00077 double min = sign*-c; 00078 double max = sign*-c; 00079 for (int i=n; i--; ) 00080 if (ts[i].a > 0) { 00081 min += ts[i].a*ts[i].x.min(); 00082 max += ts[i].a*ts[i].x.max(); 00083 } else { 00084 max += ts[i].a*ts[i].x.min(); 00085 min += ts[i].a*ts[i].x.max(); 00086 } 00087 if (min < Limits::Int::int_min) 00088 min = Limits::Int::int_min; 00089 if (max > Limits::Int::int_max) 00090 max = Limits::Int::int_max; 00091 IntVar x(home, static_cast<int>(min), static_cast<int>(max)); 00092 ts[n].x = x; 00093 ts[n].a = -1; 00094 Int::Linear::post(home, ts, n+1, IRT_EQ, sign*-c, icl); 00095 return x; 00096 }
Le code source émane d'une librairie C++ (Gecode)
Le code source mis ci-dessus est bien celui du bon fichier (etc )
Ce qui est étrange c'est qu'au sein de la boucle "for" (lignes 79 à 86), la variable "i" n'est jamais incrémentée, pourtant gdb indique que sa valeur (=3) est supérieure à sa valeur d'initialisation (=2)...
Y comprenez vous quelque chose ?
Partager