Your code should be taken out back, lined up against a wall, and machine-gunned
1–10 of 76 posts
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#2 Then the bleeding corpse should be hung, drawn and quartered.
Then burnt.
Then the smouldering rubble should be jumped up and down on.
By a hippo.
By a hippo....Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#3st1 = (void *)malloc(5000) + 5000;
completely invalid too? You can't (I think it's undefined) increment a void pointer.
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#4Why was he complaining about the stack pointer first? Isn't this line: st1 = (void *)malloc(5000) + 5000; completely invalid too? You can't (I think it's undefined) increment a void pointer.
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#5Why was he complaining about the stack pointer first? Isn't this line: st1 = (void *)malloc(5000) + 5000; completely invalid too? You can't (I think it's undefined) increment a void pointer.
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#6Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#7Then the bleeding corpse should be hung, drawn and quartered. Then burnt. Then the smouldering rubble should be jumped up and down on. By a hippo. By a hippo....
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#8Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#9Why was he complaining about the stack pointer first? Isn't this line: st1 = (void *)malloc(5000) + 5000; completely invalid too? You can't (I think it's undefined) increment a void pointer.
It may be undefined, but gcc accepts it without warning under -Wall and does exactly what you'd expect. Note that (a) casting malloc's return is evil, (b) casting malloc to void* is silly since it's declared returning void* already, and (c) casting malloc to void* so it can be received as a char* is also pretty goofy.
My C is a bit rusty, but how else are you meant to allocate data of different types on the heap?
Re: Your code should be taken out back, lined up against a wall, and machine-gunned
#10Why was he complaining about the stack pointer first? Isn't this line: st1 = (void *)malloc(5000) + 5000; completely invalid too? You can't (I think it's undefined) increment a void pointer.
Yep, it's basically undefined because a void type has no known size to do pointer arithmetic with.