Date: Sun, 26 Jan 2025 22:41:55 +0100
You say:
> but yet it can create a Frog* or a Monkey*
Are you talking about p and p2? Then it is about the pointers itself, not the objects they point to.
Or are you talking about the (both) nullptr? Then it is a special pointer value.
For creating a true pointer, you would need the address-of or new operator or a function returning a pointer.
All ways to really create a Frog or Monkey in memory call the constructor and need the full definition including information about alignment.
Or are you mostly referring to how many bits pointers need and how they are stored?
What difference would it make and when?
Pointer tagging? https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3125r3.html
(1) is surely not true, there are different alignments
(2) whether it is true is depending on what you mean by intercompatible and by same size
-----Ursprüngliche Nachricht-----
Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:So 26.01.2025 22:25
Betreff:Re: [std-proposals] Make all data pointers intercompatible
An:std-proposals <std-proposals_at_[hidden]>;
CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
Eight months ago, I posted here saying that all pointer types should
be made intercompatible. Here's my original post:
https://lists.isocpp.org/std-proposals/2024/05/9773.php
With all the talk today on the topic of "Public inheritance with
banned conversion to base", I've just realised something. Consider the
following two classes:
struct Frog {
char c;
};
struct Monkey {
long long n;
};
Frog has an alignment of 1, whereas Monkey has an alignment of 8. So a
pointer to a Frog could possibly need more bits than a pointer to a
Monkey.
But now let's consider another translation unit in the same program:
struct Frog;
struct Monkey;
int main(void)
{
Frog *p = nullptr;
Monkey *p2 = nullptr;
}
This second translation unit doesn't know the alignment requirements
of either Frog or Monkey, but yet it can create a Frog* or a Monkey*.
This means that one of the following must be true:
(1) Any given class type will have its alignment requirements made
more restrictive so that any "basic pointer" can point to it.
(2) All pointers type are intercompatible and the same size.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-01-26 21:45:28