User forums > General (but related to Code::Blocks)

Aparent error in Code Blocks

<< < (2/2)

venom4u31:

--- Quote from: ollydbg on March 06, 2012, 01:04:07 am ---@OP
Please post your code snippet so that I can test it.

In fact, I'm not fully understand what's OP's problem, what is the watch expression, and what's the exact value it should be? Please list them.


--- End quote ---

To have the code working there are several files that need to be working. If you want I can paste the basic structure of v to make you understand what it is about.

--- Code: ---//v is a TMult element that represents a structure that can hold any type of element


typedef int(*TFComp)(const void *, const void *);
typedef struct
{ size_t d;        /* element size */
  TFComp fid;      /* function that checks the equality of two elements */
  TFComp ord;      /* ordering function */
  void *v, *s, *t; /* value vector adresses: v for beginning, s for end of used memory and t for available memory */
} TMult;



--- End code ---

Regarding values, I think it's pretty clear. The vector v->v is listed (it's void with int values in it), the initialization of s1 is clear: it's v->v+j (j=0 and d=1, j, d are int numbers). And s2=v->v+j+d which is supposed to be s1+1. Now, s1 is correctly v->v, as it says there, its value is 1. However s2, although it holds the exact same memory address as v->v+j+d, instead of having the value 23 in it, it has a huge number stored.

ollydbg:
Ok, you can do:

1, download the debugger branch nightly build version
2, enable the full debug log output
3, past all the debugger's debug log text when you watch those variables.

Mean while, I will test your sample code too.

ollydbg:
So, what's your problem? Here is my test code and see the screen shot below:

code:

--- Code: ---#include <stdio.h>

//v is a TMult element that represents a structure that can hold any type of element

typedef int(*TFComp)(const void *, const void *);


typedef struct
{ size_t d;        /* element size */
  TFComp fid;      /* function that checks the equality of two elements */
  TFComp ord;      /* ordering function */
  void *v, *s, *t; /* value vector adresses: v for beginning, s for end of used memory and t for available memory */
} TMult;


TMult a;

int main()
{
    TMult *p = &a;
    p->v = (void*)0x1;
    p->s = (void*)0x2;
    return 0;
}



--- End code ---
screen shot:



I can't see any thing wrong.

EDIT: would you mind to extend my example to show us the errors?

Jenna:
Please create a simple working example, that shows the issue, not just a stub.

From what I see, the issue most likely occurs because of incorrect referencing/dereferncing of pointers, probably caused by a lack of basic programming knowledge.

Be aware, that this forum/website, does not teach programming and is not meant to find programming errors (if they are not inside C::B's own code).
Such questions violate our forum rules, and every user has accepted these rules with registering here.

So your topic might get locked !

venom4u31:

--- Quote from: jens on March 06, 2012, 09:36:09 am ---Please create a simple working example, that shows the issue, not just a stub.

From what I see, the issue most likely occurs because of incorrect referencing/dereferncing of pointers, probably caused by a lack of basic programming knowledge.

Be aware, that this forum/website, does not teach programming and is not meant to find programming errors (if they are not inside C::B's own code).
Such questions violate our forum rules, and every user has accepted these rules with registering here.

So your topic might get locked !


--- End quote ---

I'm sorry, I didn't want or expect to have the code solved or a valid solution provided. I just wanted to know a possible reason for which such a thing might happen. Since I didn't find any logical reason for two pointers initialized the same way to have completely different values, I thought that might have happened because a code::blocks error.

Navigation

[0] Message Index

[*] Previous page

Go to full version