H
hardwareman
Hi Folks,
I can work around this problem, but it shows a problem in my
understanding of how things should work. Any ideas are appreciated.
Thanks,
Hardwareman
When the following subroutine is put inline the results are expected.
When the reference to the vector is passed, the reference has the
correct sizes but the 'Print' member function spews almost random junk.
BLAH is an unordinary user class containing scalars.
typedef vector<BLAH> EntryBram_T ;
typedef vector<EntryBram_T> Expected_T ;
void C_PrintExpected ( Expected_T & expected ) {
for (int i=0 ; i < expected.size() ; i++) {
Msg(MSG_LOW, "%m: C_PrintExpected: terminal=%d list size=%d\n",
i, expected.size() ) ;
int j = 0 ;
// print out all expected entries
while (j < expected.size() ) {
(expected)[j].Print(j++) ;
}
}
}
The calling function:
expected[ term ].push_back( EntryBram[original_start] ) ;
Msg(MSG_LOW, "%m: Print what we just pushed\n") ;
(expected[ term ].end()-1)->Print(original_start) ; // this is
fine
C_PrintExpected(expected) ; // THIS IS
WRONG
// This inline code works as expected
for (int i=0 ; i < expected.size() ; i++) {
Msg(MSG_LOW, "%m: C_PrintExpected inline: terminal=%d list
size=%d\n",
i, expected.size() ) ;
int j = 0 ;
// print out all expected entries
while (j < expected.size() ) {
(expected)[j].Print(0) ;
j++ ;
}
}
////////////////
RUN RESULTS:
BAD :
C_PrintExpected: terminal=0 list size=1
BLAH:rint add=0x0000: mac=00:00:01 hdlc_len=0x000
GOOD :
C_PrintExpected inline: terminal=0 list size=1
BLAH:rint add=0x0000: mac=23:24:25 hdlc_len=0x031
I can work around this problem, but it shows a problem in my
understanding of how things should work. Any ideas are appreciated.
Thanks,
Hardwareman
When the following subroutine is put inline the results are expected.
When the reference to the vector is passed, the reference has the
correct sizes but the 'Print' member function spews almost random junk.
BLAH is an unordinary user class containing scalars.
typedef vector<BLAH> EntryBram_T ;
typedef vector<EntryBram_T> Expected_T ;
void C_PrintExpected ( Expected_T & expected ) {
for (int i=0 ; i < expected.size() ; i++) {
Msg(MSG_LOW, "%m: C_PrintExpected: terminal=%d list size=%d\n",
i, expected.size() ) ;
int j = 0 ;
// print out all expected entries
while (j < expected.size() ) {
(expected)[j].Print(j++) ;
}
}
}
The calling function:
expected[ term ].push_back( EntryBram[original_start] ) ;
Msg(MSG_LOW, "%m: Print what we just pushed\n") ;
(expected[ term ].end()-1)->Print(original_start) ; // this is
fine
C_PrintExpected(expected) ; // THIS IS
WRONG
// This inline code works as expected
for (int i=0 ; i < expected.size() ; i++) {
Msg(MSG_LOW, "%m: C_PrintExpected inline: terminal=%d list
size=%d\n",
i, expected.size() ) ;
int j = 0 ;
// print out all expected entries
while (j < expected.size() ) {
(expected)[j].Print(0) ;
j++ ;
}
}
////////////////
RUN RESULTS:
BAD :
C_PrintExpected: terminal=0 list size=1
BLAH:rint add=0x0000: mac=00:00:01 hdlc_len=0x000
GOOD :
C_PrintExpected inline: terminal=0 list size=1
BLAH:rint add=0x0000: mac=23:24:25 hdlc_len=0x031