Questions tagged [dereference]

Anything related to pointer dereference, i.e. the process of determining the object which the pointer is referring to. Languages having pointer variables usually have a special operator to perform dereferencing of pointers (e.g. in C and C++, if `p` is a valid pointer, `*p` is the object pointed to by `p`).

Anything related to pointer dereference, i.e. the process of determining the object which the pointer is referring to. Languages having pointer variables usually have a special operator to perform dereferencing of pointers (e.g. in C and C++, if p is a valid pointer, *p is the object pointed to by p).

1184 questions
4
votes
1 answer

Can TAR both record symbolic links and the files/directories they reference?

The Tar command has an -h flag to follow symbolic links instead of recording the symbolic links. Is it possible to have both the symbolic links and what they point to in the archive? Can this be done automatically in one run of the TAR command?
user553702
  • 2,819
  • 5
  • 23
  • 27
4
votes
2 answers

About iterator of containers

I do not know, why does it output 1024? vector default_container = { 1,2,3,4,5,6,7,78,8,1024 }; cout << *default_container.end() << endl; // 0 default_container.pop_back(); for (auto it : default_container) { cout << it << ","; } cout <<…
littleZ
  • 71
  • 2
4
votes
1 answer

Inline dereferencing method return parameters

I've seen several ABAP standard methods that return a reference to data as result. CL_ABAP_EXCEPTIONAL_VALUES=>GET_MAX_VALUE( ) is one of those methods. My natural inclination is to use this method in a single line, like this: DATA lv_max_value TYPE…
Zero
  • 1,562
  • 1
  • 13
  • 29
4
votes
5 answers

What is the difference between derefencing and assigning the address of a variable to pointer variable in C?

See the two codes below! int main() { int a = 12; int *p; *p = a; } and the this code, int main() { int a = 12; int *p; p = &a; } In the first piece of code dereferenced the pointer as this *p = a, and in the second piece…
Azeem Muzammil
  • 262
  • 1
  • 3
  • 14
4
votes
6 answers

Why do we have to cast a void pointer to int or something else before printing the value in the memory whose address is in the pointer?

I wonder why is it necessary to cast a void pointer to an int * or char * before printing the contents of the address in memory, even though we tell the printf() function how to interpret the data in memory? Let's say that we have the following…
user8613421
4
votes
2 answers

How to accelerate pointer dereferencing?

Here's my code: #include //malloc #define lineSize 16 #define columnSize 16 #define cellSize 16 int main() { unsigned char*** tab; tab = malloc(sizeof(unsigned char**) * lineSize); for(unsigned int i = 0; i < lineSize; i++) …
Tom Clabault
  • 481
  • 4
  • 18
4
votes
3 answers

Is it possible to dereference something inside of a dereference in assembly?

Consider the following procedure that fills a dword array with values, and takes in 2 parameters: at EBP + 08h is the size of the array, and at EBP + 0Ch is the offset of the given array. (i.e. OFFSET myarray): MyProc PROC PUSH EBP MOV EBP, ESP SUB…
mike bayko
  • 375
  • 5
  • 20
4
votes
3 answers

c++ Possible null pointer dereference

I ran cppcheck over some code to look for possible runtime errors. And it is reporting a possible null pointer dereference with the following situation: Foo* x = ... //defined somewhere ... Foo* y(x); //possible null pointer dereference. Edit:…
Glaeken
  • 41
  • 1
  • 3
4
votes
1 answer

When do I use **kwargs vs kwargs (*args vs args)?

I need to store both args & kwargs in a tuple for calling later, so in that case would the appropriate value in the tuple *args or args? In other words, will this work: def __init__(self, *args, **kwargs): self._buildCalls = [ …
4
votes
3 answers

How does dereference operator (*) work when overloaded as a member function of a class?

When I looked up books and stack overflow article on operator overloading, I found the following: When an overloaded operator is a member function, this is bound to the left-hand operand. Member operator functions have one less (explicit) …
4
votes
1 answer

Python tarfile: how to use tar+gzip compression with follow symbolic link?

How could I use tar+gzip compression with "follow symbolic link" feature in Python 3.4? The problem is: tarfile.open() supports "w:gz" mode but does not support "dereference" option tarfile.tarfile() supports "dereference" but does not support…
Balint
  • 45
  • 8
4
votes
3 answers

How and when to properly use *this pointer and argument matching?

When I go thru the code written by collegue, in certain place, they use: this->doSomething(); //-->case A doSomething(); //-->case B In fact I'm not sure about the great usage of *this pointer...:( Another question with argument…
wengseng
  • 1,330
  • 1
  • 14
  • 27
4
votes
1 answer

When should "&" be used on both sides of an assignment?

The Condvar docs shows an example that includes the following: let pair = Arc::new((Mutex::new(false), Condvar::new())); // let &(ref lock, ref cvar) = &*pair; I'm wondering what the advantage might be to including & on both…
Bosh
  • 8,138
  • 11
  • 51
  • 77
4
votes
2 answers

Are the C++ & and * operators inverses in all contexts?

I've just started learning C++ a few days ago (coming from a C# background) and am going through the headache at the moment of getting to grips with pointers and references etc. (No, I've never used pointers in C# and I'm only using them now because…
user2163043
  • 361
  • 1
  • 3
  • 14
4
votes
2 answers

dereference variable address through null structure pointer, no segmentation fault

typedef struct { int a; }stTemp_t; int main() { stTemp_t *pstTemp = NULL; int *p = &(pstTemp->a); // <<----- supposedly de-ref NULL pointer return 0; } The instruction pointed above, i thought should've caused a segmentation fault which…
Jitendra
  • 43
  • 3