#Strange behaviour

1 messages · Page 1 of 1 (latest)

willow burrowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

merry aspen
#

dereferencing a null pointer is UB thinkies

#
void test_c(struct c * v){
                     //^ v = NULL here
    printf("c2: %p -> %p -> %p\n", &v, v, *v);
}
#

Okay I'm on my phone rn so i wont test

#

But run this woth ubsan

#

Oh wait I'm just dumbyamikek

#

Oh wait you probably shouldn'tyamikek

#

But look up casting rules I guess

#

I don't really know C, the type system is very weird

#

It allows a lot of things that break stuff

chrome dagger
#

also note that you are trying to print things that are not pointers with %p

chrome dagger
#

casting a struct **a to a struct *a?

#

maybe the cast isn't UB, but de-referencing it afterwards definitely is

willow burrowBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity