C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Proposal - Allow '.' operator to work on pointers (again sortof)

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Tue, 10 Mar 2020 09:13:13 +0100

on Tue, 10 Mar 2020 00:57:56 -0700 you (J Decker via Liaison
<liaison_at_[hidden]>) wrote:

> 'doing it with (*). is a headache.' So you're saying the working in
> the C++ standard makes it difficult?

I am merely talking about C, I wouldn't know too well for C++.

> and that actually treating E1.E2 as (&E1)->E2 makes it easy?

No, not at all, you are reversing the implications. If you already
have an object of the structure type, `E1.E2` should be fine. But if
you have a pointer to an untyped object (storage instance as we tend
to call it know), `E1→E2` does not pretend that this object already
has acquired the type, yet. Such a typed object clearly only springs
into life, once you have initialized all the members with such an

And many of the aliasing analysis in C is bound to the effective type,
so if you access objects for which the effective type is not yet
determined, aliasing analysis may go wrong.

For C++ this is probably different because people are not supposed to
use `malloc` but `new` which launches a constructor, but at the
extreme you still have the same or similar rules, if I remember

But we are much taken away. To come back to the original paper, what I
was saying that it would be better to formulate the replacement rule
that is proposed to be `X.member` should rewrite to `X→member` if `X`
is a pointer. That's all.

(And I still don't like it.)


:: 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-10 03:16:03