Newbie: BGL: g++ -O2 or -O3 gives wrong numbers
HI, I start looking at the Graph library and try the quick_tour.cpp on my machine. Here is something wrong I found out
gcc --vesion gcc (GCC) 3.3 (Gentoo Linux 1.4, PVR 3.3)
g++ -o test -O2 quick_tour.cpp ./test vertices(g) = A B C D E edges(g) = (A,B) (A,D) (C,A) (D,C) (C,E) (B,D) (D,E) vertex: 0 out-edges: (0,134545512) (0,134545536) in-edges: (2,0) adjacent vertices: 134545512 134545536 vertex: 1 out-edges: (1,134545632) in-edges: (0,1) adjacent vertices: 134545632 vertex: 2 out-edges: (2,134545560) (2,134545608) in-edges: (3,2) adjacent vertices: 134545560 134545608 vertex: 3 out-edges: (3,134545584) (3,134545656) in-edges: (0,3) (1,3) adjacent vertices: 134545584 134545656 vertex: 4 out-edges: in-edges: (2,4) (3,4) adjacent vertices: digraph G { graph [ rankdir="LR", ratio="fill", size="3,3"]; node [ shape="circle"]; 0[label="A"]; 1[label="B"]; 2[label="C"]; 3[label="D"]; 4[label="E"]; 0->1 [label="1.2"]; 0->3 [label="4.5"]; 2->0 [label="2.6"]; 3->2 [label="0.4"]; 2->4 [label="5.2"]; 1->3 [label="1.8"]; 3->4 [label="3.3"]; }
Note: the large numbers in the out-edges , like 134545512. Expected numbers are 0,1,2,3,4. Seems some fields are not initilized but read. Note: I tried gcc-3.2.3 and got same results Note: Without -O2 it is fine. My newbie questions are: 1) Is it compiler issue or BGL issue? Cannot we use optimization of gcc when using BGL? 2) I suppose gcc3.3 is good so if this is an BGL issue, where could the thing go wrong? How to fix it? Thanks, Michael
michael_wangzy wrote:
HI, I start looking at the Graph library and try the quick_tour.cpp on my machine. Here is something wrong I found out
gcc --vesion gcc (GCC) 3.3 (Gentoo Linux 1.4, PVR 3.3)
g++ -o test -O2 quick_tour.cpp ./test vertices(g) = A B C D E edges(g) = (A,B) (A,D) (C,A) (D,C) (C,E) (B,D) (D,E) vertex: 0 out-edges: (0,134545512) (0,134545536)
...
Note: the large numbers in the out-edges , like 134545512. Expected numbers are 0,1,2,3,4. Seems some fields are not initilized but read.
Hmm... here with 3.3 on Debian it works ok. Do you have 'valgrind' utility installed or easily installable on your box. If so, you might run valgrind test and tell if it spots any uninitialized memory reads. If that does not help, I'm at loss... - Volodya
On Tue, 2003-06-17 at 14:45, Vladimir Prus wrote:
michael_wangzy wrote:
HI, I start looking at the Graph library and try the quick_tour.cpp on my machine. Here is something wrong I found out
gcc --vesion gcc (GCC) 3.3 (Gentoo Linux 1.4, PVR 3.3)
g++ -o test -O2 quick_tour.cpp ./test vertices(g) = A B C D E edges(g) = (A,B) (A,D) (C,A) (D,C) (C,E) (B,D) (D,E) vertex: 0 out-edges: (0,134545512) (0,134545536)
...
Note: the large numbers in the out-edges , like 134545512. Expected numbers are 0,1,2,3,4. Seems some fields are not initilized but read.
Hmm... here with 3.3 on Debian it works ok.
AFAIK Gentoo is a source based distro, which means you've built the compiler yourself at some point (or Gentoo has done it for you). Maybe some subtle error was introduced when building the compiler and/or standard library?
Do you have 'valgrind' utility installed or easily installable on your box. If so, you might run
valgrind test
and tell if it spots any uninitialized memory reads. If that does not help, I'm at loss...
If it doesn't something is seriously wrong, most likely with your compiler build. You can get Valgrind here btw: http://devel-home.kde.org/~sewardj/ -- Tarjei
participants (3)
-
michael_wangzy
-
Tarjei Knapstad
-
Vladimir Prus