Re: [cocci] Reconsidering pointer dereferences before null pointer checks (with SmPL)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 10 Apr 2023, Markus Elfring wrote:

> >>> Setting var to &input->member does not cause any immediate problem.
> >>
> >> Undefined behaviour would be involved if the expression variable “input”
> >> will actually be resolved to a null pointer, wouldn't it?
> >
> > No.  &input->member adds an offset to the address of input.
>
> It seems that we represent different development views according to the question
> “Does taking address of member variable through a null pointer yield undefined behavior?”.
> https://stackoverflow.com/questions/25725286/does-taking-address-of-member-variable-through-a-null-pointer-yield-undefined-be
> https://en.cppreference.com/w/c/language/behavior

The statement:

"... &((*ptr).second) which dereferences an object instance pointer"

is not correct.  &((*ptr).second) does not dereference *ptr any more than
&x deferences x.  The semantics of & doesn't work like that.

julia

>
>
> Regards,
> Markus
>

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux