Click here to Skip to main content
15,908,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson16-Dec-08 19:40
professionalStuart Dootson16-Dec-08 19:40 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa16-Dec-08 19:50
Mustafa Ismail Mustafa16-Dec-08 19:50 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson16-Dec-08 21:52
professionalStuart Dootson16-Dec-08 21:52 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa16-Dec-08 23:50
Mustafa Ismail Mustafa16-Dec-08 23:50 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 2:34
professionalStuart Dootson17-Dec-08 2:34 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 4:47
Mustafa Ismail Mustafa17-Dec-08 4:47 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 5:18
professionalStuart Dootson17-Dec-08 5:18 
GeneralRe: Dangling pointers and incorrect data being written [modified] Pin
Mustafa Ismail Mustafa17-Dec-08 5:52
Mustafa Ismail Mustafa17-Dec-08 5:52 
I've pinpointed the exact location where the error takes place.

Guess what? Its a const correctness issue.

Simulator::CreateCacheSets()
{
...
getCacheSets[setIx].getCacheBlocks().push_back(getCacheBlocks()[i]);
...
}

getCacheBlocks() returns a const object. I'm surprised a compile time error was not thrown. Do I overload the method?

[update]
I've fixed it, but its the ugliest hack I've ever done.
<br />
//v[setIx].getCacheBlocks().push_back(getCacheBlocks()[i]);<br />
/*<br />
Can't do it this way, the getCacheBlocksMethod is const, so, we're doing it the crappy way<br />
which is making equivalent objects and setting them<br />
*/<br />
    vector<cacheblock> cbs;<br />
    for(uint i = 0; i < numBlocks; i++)<br />
    {<br />
        ba = getCacheBlocks()[i].getBlockAddress();<br />
        setIx = ba % numSets;<br />
        cbs = v[setIx].getCacheBlocks();<br />
	cbs.push_back(this->getCacheBlocks()[i]);<br />
	v[setIx].setCacheBlocks(cbs);<br />
    }<br />
</cacheblock>


Just sick and as ugly as sin.

Stuart, thanks a million mate for all your patience. When I do pass by Brittania, an hour's worth of pints is on me Smile | :)

Don't forget to vote if the response was helpful


Sig history

"dad" Ishmail-Samuel Mustafa

Unix is a Four Letter Word, and Vi is a Two Letter Abbreviation

"There is no wealth like knowledge, no poverty like ignorance" Ali Ibn Abi Talib

modified on Wednesday, December 17, 2008 12:14 PM

GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 6:25
professionalStuart Dootson17-Dec-08 6:25 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 6:35
Mustafa Ismail Mustafa17-Dec-08 6:35 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:12
Mustafa Ismail Mustafa14-Dec-08 21:12 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:26
Mustafa Ismail Mustafa14-Dec-08 21:26 
QuestionDevelop CSP in XP Pin
izyani14-Dec-08 19:48
izyani14-Dec-08 19:48 
QuestionUsing Queue Timers...... Pin
shaina223114-Dec-08 19:22
shaina223114-Dec-08 19:22 
AnswerRe: Using Queue Timers...... Pin
Sarath C15-Dec-08 2:16
Sarath C15-Dec-08 2:16 
AnswerRe: Using Queue Timers...... Pin
Mark Salsbery15-Dec-08 11:27
Mark Salsbery15-Dec-08 11:27 
QuestionUpdating window data from other window Pin
kiranin14-Dec-08 19:16
kiranin14-Dec-08 19:16 
AnswerRe: Updating window data from other window Pin
Franck Paquier14-Dec-08 23:23
Franck Paquier14-Dec-08 23:23 
AnswerRe: Updating window data from other window Pin
ThatsAlok15-Dec-08 0:07
ThatsAlok15-Dec-08 0:07 
Questionhow to enumerate all the subwindows in a specified process? Pin
kcynic14-Dec-08 16:43
kcynic14-Dec-08 16:43 
AnswerRe: how to enumerate all the subwindows in a specified process? Pin
Sarath C14-Dec-08 18:34
Sarath C14-Dec-08 18:34 
AnswerRe: how to enumerate all the subwindows in a specified process? [modified] Pin
kcynic14-Dec-08 19:31
kcynic14-Dec-08 19:31 
QuestionHello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
nah133714-Dec-08 11:05
nah133714-Dec-08 11:05 
AnswerRe: Hello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
Mark Salsbery14-Dec-08 11:55
Mark Salsbery14-Dec-08 11:55 
GeneralRe: Hello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
nah133714-Dec-08 19:11
nah133714-Dec-08 19:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.