Well, I was recently surprised by this state of things: Evaluating a state containing a unified pointer is UB, but can it crash?
It looks like this:
int *p; if(p != NULL) { int k; }
could theoretically end.
My question is: when can I check the value of a pointer? When can I check: if(ptr == SomeValue)- so that it does not call UB?
if(ptr == SomeValue)
It is safe to check the value of an initialized automatic variable. Pointers are no exception.
This is set out in section 6.3.2.1 and paragraph 2 in C.11:
, sizeof, &, ++, -- . , l, , , ( lvalue); lvalue conversion.... l , ( ), , ( ), .
&
++
--
.
Source: https://habr.com/ru/post/1532255/More articles:In iOS7.1 UIButton, the installed image does not work? - iosHow can I call the server side button click function? - javascriptTrying to get data from a web page with VBA code, but sometimes it works, and sometimes it doesn’t extract - excel-vbajQuery UI draggable - if an item is being dragged - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1532254/programatically-access-your-own-icloud-data-from-a-desktop-or-from-a-server&usg=ALkJrhgJcBNC44khS4i_NcIQj96QQvzzxQAssessing the state containing a unified pointer is UB, but can it fail? - cOpen HTML in browser - htmlАльтернатива BlockCopy, которая позволяет мне выбирать конечность - c#my first application stopped working with an error - androidPolynomial-time algorithm for a traveling salesman in a grid - algorithmAll Articles