- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Folks,
I can't see why I am getting this error.
aeroParams is a CarComponent variable: -
I do think that both the CarComponent and the ComponentProperty are correctly. Any idea what the problem could be?
Thanks for your help
All the best,
Ash
I can't see why I am getting this error.
[cpp]void AeroDynamics::setWingsFromParams() { ComponentPropertyPtr fw = _aeroParams->prop("FrontWingAngle"); ComponentPropertyPtr rw = _aeroParams->prop("RearWingAngle"); _frontWingDegrees = fw->valueFloat(); _rearWingDegrees = rw->valueFloat(); _frontWingAeroCoeff->setPrimaryAngleDegrees(_frontWingDegrees); _frontWingAeroCoeff->setSecondaryAngleDegrees(_rearWingDegrees); _rearWingAeroCoeff->setPrimaryAngleDegrees(_rearWingDegrees); _dragAeroCoeff->setPrimaryAngleDegrees(_frontWingDegrees); _dragAeroCoeff->setSecondaryAngleDegrees(_rearWingDegrees); }[/cpp]I am getting a "Uninitialized partial memory access" error on line 8. When I trace the fw variable contains properly initialized variables.
aeroParams is a CarComponent variable: -
[cpp]class ComponentProperty{ public: string name; string valueString; bool dynamic; string defaultValue; float min,max; float valueFloat(){ float res = atof(valueString.c_str()); return res; } int valueInt(){ return atoi(valueString.c_str()); } float valuePercent(){ return 100.0f * (valueFloat() - min) / (max-min); } void setValuePercent(float percent){ float ratio = MathUtil::limit(percent,0.0f,100.0f) / 100.0f; float val = (ratio * (max - min)) +min; valueString = STR(val); } ComponentProperty(){ name = ""; valueString = ""; dynamic = false; defaultValue = ""; min = -; max = 0; } }; typedef std::shared_ptrComponentPropertyPtr; typedef std::map ComponentPropertyList; typedef std::shared_ptr ComponentPropertyListPtr; class CarComponent{ public: CarComponent(){ ownedByPlayer = false; price = 0; componentId = carId = type = name = filename = description = picture = ""; }
string componentId; string carId; string type; string name; string filename; bool ownedByPlayer; // Only used when transferring to menus, don't trust otherwise int price; // In credits ComponentPropertyList propertyList; string description; string picture; SPTRprop(const string &propName){ auto res = propertyList.find(propName); if (res == propertyList.end()){ throw "Property Not Found"; }else{ return res->second; } } private: }; typedef std::shared_ptr CarComponentPtr; typedef std::vector CarComponentList; typedef std::shared_ptr CarComponentListPtr;[/cpp]
I do think that both the CarComponent and the ComponentProperty are correctly. Any idea what the problem could be?
Thanks for your help
All the best,
Ash
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually from the stack trace it is complaining about _threadhandle (line 8 above is aerodynamics.cpp:154)
Any idea what the problem could be?
[plain]MSVCR100.dll!_threadhandle - :0x000230b0 MSVCR100.dll!swab - :0x0002328e MSVCR100.dll!swab - :0x00023357 MSVCR100.dll!swab - :0x00023386 Orc.exe!setWingsFromParams - aerodynamics.cpp:154 Orc.exe!AeroDynamics - aerodynamics.cpp:67 Orc.exe!initDefaults - vehicle.cpp:483 Orc.exe!Vehicle - vehicle.cpp:165 Orc.exe!initCarPhysics - mastercarobject.cpp:146 Orc.exe!init - mastercarobject.cpp:92 Orc.exe!loadCar - cardatamanager.cpp:199 Orc.exe!switchPlayerCar - gameeventhandler.cpp:1753 Orc.exe!initRace - gameeventhandler.cpp:1784[/plain]
Any idea what the problem could be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The message about "partial" typically means size difference. It looks like the right hand side of line 8 is a float. if the left hand side is a double - that might be why Intel Parallel Inspector might be reporting a diagnostic. The recipient is larger than what is being provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David,
Thanks for your reply. Both sides are floats in this case. Any other reasons as to why there would be a problem?
Thanks!
Ash
Thanks for your reply. Both sides are floats in this case. Any other reasons as to why there would be a problem?
Thanks!
Ash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David,
Thanks for the tip, I tracked it down to the atof. I switched the functionality so that when the value is set the atof is done then rather than in the valueFloat. This has reduced the amount of errors reported greatly.
I do think this is a bug, conversions like this shouldn't be marked as an error IMO, especially as it's explicitly cast.
Thanks again!
All the best,
Ash
Thanks for the tip, I tracked it down to the atof. I switched the functionality so that when the value is set the atof is done then rather than in the valueFloat. This has reduced the amount of errors reported greatly.
I do think this is a bug, conversions like this shouldn't be marked as an error IMO, especially as it's explicitly cast.
Thanks again!
All the best,
Ash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Ash,
I did some tests here to reproduce the issue here. Below is what I am doing.
(Note: I have ensured that the function "atof" is getting called in the below code.)
char bank_balance_str[20];
scanf("%s", bank_balance_str); //reading a floating point value from the user
float bank_balance_float = atof((const char*)bank_balance_str);
double bank_balance_double = bank_balance_float;
Please let me know if your code is doing something different from the above.
Inspector XE did not report any problems although the C++ compiler warned about possible loss of data when assigning a double (atof returns a double) to a float type variable. Could you please send me some code snippets that I can try here?
Also, can you please tell me the datatype of the variable "_frontWingDegrees" in your code?
We greatly appreciate you being very active in the forum.
Regards,
Krishna
I did some tests here to reproduce the issue here. Below is what I am doing.
(Note: I have ensured that the function "atof" is getting called in the below code.)
char bank_balance_str[20];
scanf("%s", bank_balance_str); //reading a floating point value from the user
float bank_balance_float = atof((const char*)bank_balance_str);
double bank_balance_double = bank_balance_float;
Please let me know if your code is doing something different from the above.
Inspector XE did not report any problems although the C++ compiler warned about possible loss of data when assigning a double (atof returns a double) to a float type variable. Could you please send me some code snippets that I can try here?
Also, can you please tell me the datatype of the variable "_frontWingDegrees" in your code?
We greatly appreciate you being very active in the forum.
Regards,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Krishna,
_frontWingDegrees is declared as float. The only difference I can see in the code is that bank_balance_str is a char array rather than a string. I've heard that there are some memory problems with strings in VS 2010 (non-SP1) that are fixed in SP1. I am using VS 2010(non-SP1) at the moment.
Perhaps that is the problem. I also get similar problems reported when I'm putting a float into a file stream (with my log files). Perhaps it is converting using a atof too?
Are you using VS 2010 to test? It may be that VS 2010 is at fault here?
All the best,
Ash
_frontWingDegrees is declared as float. The only difference I can see in the code is that bank_balance_str is a char array rather than a string. I've heard that there are some memory problems with strings in VS 2010 (non-SP1) that are fixed in SP1. I am using VS 2010(non-SP1) at the moment.
Perhaps that is the problem. I also get similar problems reported when I'm putting a float into a file stream (with my log files). Perhaps it is converting using a atof too?
Are you using VS 2010 to test? It may be that VS 2010 is at fault here?
All the best,
Ash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I am using VS 2010 but can't see how that could be a problem. I will try using string now and see what happens. Thanks for the above note, Ash.
--krishna
--krishna

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page