Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » Bug (?) in ide\Debuggers\Exp.cpp
Bug (?) in ide\Debuggers\Exp.cpp [message #3394] Tue, 23 May 2006 12:25 Go to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
(I'm just trying to figure out why the "data[2]" does lead to "Only pointer can be dereferenced" ... still reading the Exp.cpp + parser.cpp classes, I will need probably some more time (like couple of days, as I have just couple of minutes per day for Ultimate++) to get familiar with those classes)

I found out suspicious code in Exp.cpp (line 136, 605dev1 src):
Pdb::Val Pdb::Compute(Pdb::Val v1, Pdb::Val v2, int oper)
{
	if(v1.ref) {
		int q = (int)GetInt(v2) * (v1.ref > 1 ? 4 : SizeOfType(v1.type));
		v1 = GetRVal(v1);
		switch(oper) {
		case '+': v1.address += q; break;
		case '-': v1.address -= q; break;
		default: ThrowError("Invalid pointer arithmetics");
		}
		return v1;
	}
	if(v1.ref) {
		int q = (int)GetInt(v1) * (v2.ref ? 4 : SizeOfType(v2.type));
		v2 = GetRVal(v2);
		if(oper == '+')
			v2.address += q;
		else
			ThrowError("Invalid pointer arithmetics");
		return v2;
	}


Looks to me like the second if should be:
if (v2.ref) {

Besides that it looks to me like (almost) duplicite code... which I personally quite dislike, when it can be avoided easily.
Maybe some
Pdb::val & _v1 = v1;
Pdb::val & _v2 = v2;
if (!v1.ref && v2.ref) _v1 = v2, _v2 = v1;
//further _v1 and _v2 are used instead of v1/v2

would be more elegant and more powerful (supporting "-" operator even if v2 is "ref"), but I don't have enough insight into the code to judge whether the "more powerful" part is actually needed, or counterproductive. And it would maybe still look somewhat cumbersome anyway. (And I didn't try that proposal, so I'm not sure if it doesn't have some further catch.)

Edit: now I'm not sure if _v1 = v2 would not overwrite also original v1 content ... probably yes?
Once the reference is set, how to change it in C++?
I already forgot how references work exactly (as I do use plain C in work right now, for last year or so)... Sad Maybe I should check the C++ language reference again.

[Updated on: Tue, 23 May 2006 12:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Automatic file encoding
Next Topic: Possible bug
Goto Forum:
  


Current Time: Sun May 12 03:49:31 CEST 2024

Total time taken to generate the page: 0.02610 seconds