[Qt-creator] Proposal: Adding std::(experimental::)optional
charleyb123 .
charleyb123 at gmail.com
Fri Aug 26 17:20:33 CEST 2016
On Fri, Aug 26, 2016 at 9:08 AM, Christian Kandeler <
christian.kandeler at qt.io> wrote:
> On 08/26/2016 04:49 PM, charleyb123 . wrote:
> > An aside: We are currently steeped in the tradition that "zero" is not
> > a legal address, but that is (quickly) becoming not-true for
> > process-containers, system-emulators and VMs, and new hardware
> > (including new CPUs).
>
> That has nothing to do with the null pointer in C(++). It never refers
> to a valid address, that's how the language is defined. If zero is a
> valid address in some environment, then it's the compiler's job to
> ensure that the null pointer maps to something else at runtime.
> That is also the reason that the following code is wrong:
> struct s { void *p; } s;
> memset(&s, 0, sizeof s); // s.p might not be a null pointer at runtime
>
Agree with what you're saying, but I'm highlighting a real-world ambiguity
as related to APIs, and as related to the compiler also.
Given a pointer on an architecture where *all* bit-patterns yield a valid
address, it is not possible for a compiler to do what you propose.
Possible work-arounds are to reserve a "well-known" address to imply a
"null-object-instance", but that's an artifact not required by the
architecture (but might be required by C(++) if we want to continue the
"null" concept.)
--charley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20160826/be6ff8f0/attachment.html>
More information about the Qt-creator
mailing list