Stream: general

Topic: pre-rfc custom DSTs


gnzlbg (Nov 07 2018 at 09:41, on Zulip):
gnzlbg (Nov 07 2018 at 09:41, on Zulip):

@Nicole Mazzuca ^^^

gnzlbg (Nov 07 2018 at 09:44, on Zulip):
Nicole Mazzuca (Nov 07 2018 at 16:02, on Zulip):

VLAs are not FAMs, to be clear

Nicole Mazzuca (Nov 07 2018 at 16:02, on Zulip):

they are in fact incredibly distinct features

Nicole Mazzuca (Nov 07 2018 at 16:02, on Zulip):

one of them is very good

Nicole Mazzuca (Nov 07 2018 at 16:02, on Zulip):

the other is a massive security risk

RalfJ (Nov 07 2018 at 16:14, on Zulip):

VLA = Variable Length Array, but FAM? Must be the Flexible Array Members you mentioned. Got to google that one^^

RalfJ (Nov 07 2018 at 16:17, on Zulip):

still would be interesting which of the two you consider good vs a risk

Nicole Mazzuca (Nov 07 2018 at 16:19, on Zulip):

FAM is the good one

Nicole Mazzuca (Nov 07 2018 at 16:19, on Zulip):

VLAs are widely considered to be a bad idea

Nicole Mazzuca (Nov 07 2018 at 16:20, on Zulip):

there's a reason they never got into C++, and that they were made optional in C11

RalfJ (Nov 07 2018 at 16:21, on Zulip):

ah I heard about the Linux kernel banning VLAs

RalfJ (Nov 07 2018 at 16:21, on Zulip):

though FAMs also seem risky because the length is not given anywhere in the type? But that is normal game in C I guess

Nicole Mazzuca (Nov 07 2018 at 16:22, on Zulip):

?

Nicole Mazzuca (Nov 07 2018 at 16:22, on Zulip):

the length is given in the type tho

RalfJ (Nov 07 2018 at 16:22, on Zulip):

looking at https://en.wikipedia.org/wiki/Flexible_array_member

Nicole Mazzuca (Nov 07 2018 at 16:22, on Zulip):

just not in the array type

Nicole Mazzuca (Nov 07 2018 at 16:23, on Zulip):
struct pascal_string {
  size_t length; // length given here
  char buffer[];
};
RalfJ (Nov 07 2018 at 16:23, on Zulip):

well that's the progrmmer writing a comment

RalfJ (Nov 07 2018 at 16:24, on Zulip):
struct example {
    char *name;
    double arr[]; // the flexible array member must be last
};

is just as legal, isn't it?

Nicole Mazzuca (Nov 07 2018 at 16:24, on Zulip):

sure

Nicole Mazzuca (Nov 07 2018 at 16:25, on Zulip):

the C++ version is quite a bit better, imo

Nicole Mazzuca (Nov 07 2018 at 16:25, on Zulip):

but that's just C

Nicole Mazzuca (Nov 07 2018 at 16:28, on Zulip):

(although the C++ version is not yet published)

RalfJ (Nov 07 2018 at 16:28, on Zulip):

was just googling it and didnt find anything yet^^

Nicole Mazzuca (Nov 07 2018 at 16:29, on Zulip):

I'm trying to find a good way to show you the formatted paper, as opposed to raw html

Nicole Mazzuca (Nov 07 2018 at 16:30, on Zulip):

https://htmlpreview.github.io/?https://github.com/ThePhD/future_cxx/blob/master/papers/d1039.html

RalfJ (Nov 07 2018 at 16:34, on Zulip):

^^

RalfJ (Nov 07 2018 at 16:36, on Zulip):

what makes it better in your opinion?

Nicole Mazzuca (Nov 07 2018 at 16:37, on Zulip):

they're just completely distinct features.

Nicole Mazzuca (Nov 07 2018 at 16:37, on Zulip):

oh, C++ rather than C?

Nicole Mazzuca (Nov 07 2018 at 16:37, on Zulip):

it puts the size in the type

RalfJ (Nov 07 2018 at 16:38, on Zulip):

ah just saw the trait stuff there

RalfJ (Nov 07 2018 at 16:38, on Zulip):

intersting

Nicole Mazzuca (Nov 07 2018 at 16:38, on Zulip):

also, it works with dtors, which is important for C++, even if it doesn't matter in C.

RalfJ (Nov 07 2018 at 16:40, on Zulip):

and which explains why they need to get the size stuff right :D

RalfJ (Nov 07 2018 at 16:40, on Zulip):

and then they make it overloadable. quite neat, yeah.

Nicole Mazzuca (Nov 07 2018 at 16:42, on Zulip):

@gnzlbg do you have links to other RFCs? I found one (mine)

Nicole Mazzuca (Nov 07 2018 at 16:43, on Zulip):

oh, nope, I apparently linked to others

gnzlbg (Nov 07 2018 at 16:43, on Zulip):

There is one RFC with open PR by Simon Sapin that addresses a tangential problem that might be worth citing

gnzlbg (Nov 07 2018 at 16:44, on Zulip):

https://github.com/rust-lang/rfcs/issues/813 mentions CStr

gnzlbg (Nov 07 2018 at 16:46, on Zulip):

There are also some RFCs about unsized rvalues, alloca etc.

gnzlbg (Nov 07 2018 at 16:47, on Zulip):

https://github.com/rust-lang/rfcs/pull/2580 that's the one by Simon

gnzlbg (Nov 07 2018 at 16:48, on Zulip):

http://smallcultfollowing.com/babysteps/blog/2014/01/05/dst-take-5/ series by @nikomatsakis
and the RFC that changed the DST trait bound syntax: https://github.com/rust-lang/rfcs/pull/490

gnzlbg (Nov 07 2018 at 16:51, on Zulip):

https://github.com/rust-lang/rfcs/pull/2310 is the original @kennytm RFC, but I think there is a rework in the works

Nicole Mazzuca (Nov 07 2018 at 16:54, on Zulip):

thanks!

kennytm (Nov 07 2018 at 16:54, on Zulip):

there was a Custom DST draft (predating ubsan's RFC 1524 IIRC) https://github.com/japaric/rfcs/blob/unsized2/text/0000-unsized-types.md

kennytm (Nov 07 2018 at 16:56, on Zulip):

(and also mikeyhew's https://internals.rust-lang.org/t/pre-erfc-lets-fix-dsts/6663 for sure)

gnzlbg (Nov 07 2018 at 16:58, on Zulip):

there is also https://github.com/rust-lang/rfcs/pull/9/files which links to the old mailing list for background..

Last update: Nov 21 2019 at 23:45UTC