Maybe the array is uninitialised.  Try printing it out.  Print any value you
don't trust.

On Feb 1, 2010 5:22 AM, "jody" <[email protected]> wrote:

Hi

In a static method of class a i have the lines
   605:  if (pLocation != NULL) {
   606:      printf("Location ok\n");
   607:  }
   608:  if (iSpecies == 0) {
   609:      printf("Species = 0\n");
   610:  }
   611:  Agent *pAgent = pLocation->getVegAgent(iSpecies);
   612:  // next line has uninitialized error
   613:  if (pAgent != NULL) {
   614:      pAgent->fromArray(pData+LOCATION_SIZE);
   615:  }

The method used in line 611 is in a different class:
   267:Agent *Cell::getVegAgent(spcid id) const {
   268:  Agent *pAgent = NULL;
   269:  if (id < NUM_VEG) {
   270:      pAgent = m_apVegetation[id];
   271:  }
   272:  // this is to check for uninitialized
   273:  if (pAgent == NULL) {
   274:      pAgent = NULL;
   275:  }
   276:  return pAgent;
   277:}

When i run my application with valgrind, the first error to appear is:
==16915== Conditional jump or move depends on uninitialised value(s)
==16915==    at 0x815A0ED:
AgentPacker::updateVegiAgentFromArray2(float*, Population const*,
unsigned int) (AgentPacker.cpp:613)

I inserted various if-statem,ents in the code above to "catch"
uninitialized variables,
but the ' if (pAgent != NULL) {' is the only one that triggers a
'Conditional jump ..' message from valgrind.
It looks like pAgent goes uninitialized between return statement line
276 in the second class and
the call in line 611.

So the first question is of course, if i have interpreted the results
correctly, i.e. pAgent is uninitialized
only after it is returned from the method, but is ok inside the method.

If this is true, how can this happen?

Thank YOu
 Jody

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the
business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to