Skip to main content
Filter by
Sorted by
Tagged with
10 votes
1 answer
733 views

Consider the following program: int main() { int* ptr = nullptr; return *ptr + 1; } (also on GodBolt) How is it, that with "decent" warnings enabled (-Wall -Wextra), both popular ...
einpoklum's user avatar
  • 137k
2 votes
1 answer
148 views

So in risc-v, for a virtual memory system, I imagine it's up to the kernel to decide if 0 is a valid memory address or not? But for machine mode, or supervisor mode, is memory address 0 valid to ...
CocytusDEDI's user avatar
0 votes
1 answer
118 views

This is some of the strangest behavior I've ever seen and I have no answer from myself. I tried -fno-delete-null-pointer-checks while compiling both my game and engine and still the same behavior was ...
Aidan's user avatar
  • 87
0 votes
1 answer
95 views

I am currently learning pointers in c. I have learned that if I do not assign an address to a pointer and try to print the value of the content of the pointer, then the program will not run properly. #...
Akib Aftermath's user avatar
0 votes
2 answers
128 views

The following code does contain UB. The gcc docu says, that the compiler can assume a pointer is non-null after it has been dereferenced. So option <1> and <2> should lead to the same ...
wimalopaan's user avatar
  • 5,552
0 votes
1 answer
60 views

I want to tokenize a provided input string using strtok(). In the first step, I want to tokenize the given string by "|" symbol. Then, I tokenize each substring by ";". Finally, I ...
Devon's user avatar
  • 1
2 votes
1 answer
119 views

Is it guaranteed by the C standard that, given type_t* x = NULL; type_t* y = NULL; we always have x > y evaluating as false? I ask because of the conversation in initial or terminal malloc buffer ...
Sasha's user avatar
  • 371
-1 votes
1 answer
376 views

I am a learning file handling in C. I tried implementing a program but no matter what I do the file pointer is still null. I checked the spelling, the directory, even tried adding and removing .txt ...
Rupa TS's user avatar
  • 19
-2 votes
1 answer
54 views

So i am trying to solve a problem to reverse a linked list and following is what i came up with. class Solution { public: /* void insertList(struct Node* head, int data) { Node* temp{ ...
electric fan's user avatar
18 votes
6 answers
5k views

From the C17 draft (6.3.2.3 ¶3): An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.67) If a null pointer constant is ...
Lover of Structure's user avatar
-1 votes
3 answers
114 views

I am getting these results. What am I doing wrong? const char *c = "\0"; cout << (c == NULL); // false cout << (c == nullptr); //false
leeway00's user avatar
  • 189
4 votes
0 answers
50 views

I’m quite sure this question has been asked before, but I just couldn’t find it. If I have a pointer that is null, e.g. a char* initialized to nullptr, is it undefined behavior (UB) to add 0 to it? I ...
Bolpat's user avatar
  • 1,775
2 votes
3 answers
540 views

I had hoped for a short, concise, elegant: std::array<int*,10> ip_arr; bool all_null = std::all_of(ip_arr.begin(),ip_arr.end(),std::is_null_ptr_as_fn); instead of inventing a lambda for that ...
Vroomfondel's user avatar
  • 2,928
0 votes
1 answer
448 views

This is my method. public boolean authenticateAndPollCallbackResult(BankIdAuthRequest bankIdAuthRequest) { ResponseEntity<BankIdAuthResponse> authResponse = bankIdAuthentication(...
Mr.Gomer's user avatar
  • 633
0 votes
0 answers
272 views

The following code gives me a warning "null pointer dereference" despite checking the pointer value before casting: struct ID { virtual ~ID() = default; }; struct IF { virtual void g() = 0; }...
αλεχολυτ's user avatar
-1 votes
2 answers
286 views

i want to know that why we use two conditions i am confused.. while head and head->next are not equal to null which means head and head's next will point to null ho is that possible int detectCycle(...
Athar Mujtaba Wani's user avatar
5 votes
2 answers
540 views

Are there any ANSI C conforming environments where all-bits-zero is not a representation for a null pointer? That is, environments where the following program would print 0? If so, can you list some ...
math4tots's user avatar
  • 8,909
0 votes
1 answer
161 views

I am currently working on a program and have run into a runtime error, ironically I cannot seem ti find the source of it at all, I have tried playing around with the char[] size, but since the problem'...
huntrese's user avatar
5 votes
2 answers
715 views

I am debugging a crash where we have a code snippet similar to - 1184 static void 1185 xyz_delete (<struct type1> *c, <struct type2> **a) 1186 { ... ... ... ... 1196 b = *a; 1197 if (...
Naman Sharma's user avatar
-1 votes
4 answers
1k views

I have a char array and I want to check if it is null. if(_char_array[0] != '\0') {...} is the same as if(_char_array != '\0') {...} thanks
KostasA's user avatar
  • 5,688
3 votes
0 answers
260 views

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res....
Gaurav Singh's user avatar
8 votes
2 answers
2k views

I'm trying to learn Fortran2018 using gfortran. When playing around with pointers I noticed that there doesn't seem to be a facility to test for nullpointers. So I have two questions: Is there really ...
Codebird's user avatar
  • 121
0 votes
0 answers
95 views

Similar question here . What I want to understand is that when current_node is NULL, the compiler doesn't see it as NULL and iterates one more time. void printBranches(struct bank *head) { ...
Mahmut Salman's user avatar
1 vote
1 answer
115 views

In this code: Pointer_pu32 points to variable a, but which is pointer Boot_st point to? int * Boot_st; int a = 15; int * Pointer_pu32 = &a; Boot_st = (int *)(*Pointer_pu32); /* what was this ...
MAK1647's user avatar
  • 11
0 votes
0 answers
16 views

I keep getting NullPointerException on all my Tests. I have a CashRegister Class with a Product object lastScannedProduct that is supposed to be initially null but then it's supposed to be changed I ...
Ondra Hrubý's user avatar

1
2 3 4 5
8