bottom type as parameter or local variable, does that make sense?

H. S. Teoh hsteoh at
Mon Jan 17 18:05:49 UTC 2022

On Mon, Jan 17, 2022 at 05:53:25PM +0000, Elronnd via Digitalmars-d wrote:
> On Monday, 17 January 2022 at 16:11:03 UTC, Timon Gehr wrote:
> > if a type `A*` is a subtype of a type `B*`, then
> > `A.sizeof>=B.sizeof`.  `noreturn*` is a subtype of any `T*`. Hence,
> > `noreturn.sizeof` should be at least `size_t.max` or even `∞`.
> I don't think this is right; it must be that A.sizeof==B.sizeof.
> Consider e.g.:
> B* f(B* b) { return b+1; }
> What happens if you pass in an A*, and A.sizeof>B.sizeof?

This is exactly what happens when you pass a derived class to a function
that expects the base class, BTW.


The problem with the world is that everybody else is stupid.

More information about the Digitalmars-d mailing list