Date: Mon, 9 Mar 2020 18:25:08 +0100
Hello,
I have to say I would not much be in favor to have that feature in C,
usually people try to make the fact that something is a pointer very
visible in C.
But then also:
> C++ Standard section 8.5.1.5 Class member access
> add:
> if the first expression of (dot) is a pointer [to an object], then
> E1.E2 is converted to (*(E1)).E2 .
Doing like this would certainly be the wrong way for C.
The two operations `E1->E2` look very similar `(*(E1)).E2` but are not
the same, in particular when evaluated in a thread context. The first
is an lvalue that is guaranteed to only access the member, where the
second forms the `*E1` object as a whole, and so may race with
accesses to other members of the same object.
Thanks
Jens
I have to say I would not much be in favor to have that feature in C,
usually people try to make the fact that something is a pointer very
visible in C.
But then also:
> C++ Standard section 8.5.1.5 Class member access
> add:
> if the first expression of (dot) is a pointer [to an object], then
> E1.E2 is converted to (*(E1)).E2 .
Doing like this would certainly be the wrong way for C.
The two operations `E1->E2` look very similar `(*(E1)).E2` but are not
the same, in particular when evaluated in a thread context. The first
is an lvalue that is guaranteed to only access the member, where the
second forms the `*E1` object as a whole, and so may race with
accesses to other members of the same object.
Thanks
Jens
-- :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS ::: :: ::::::::::::::: office Strasbourg : +33 368854536 :: :: :::::::::::::::::::::: gsm France : +33 651400183 :: :: ::::::::::::::: gsm international : +49 15737185122 :: :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
Received on 2020-03-09 12:27:56