Date: Mon, 9 Sep 2024 08:01:42 +0100 From: David Chisnall <theraven@freebsd.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: Warner Losh <imp@bsdimp.com>, Kristof Provost <kp@freebsd.org>, Alan Somers <asomers@freebsd.org>, Dmitry Salychev <dsl@freebsd.org>, Jan Knepper <jan@digitaldaemon.com>, FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: The Case for Rust (in any system) Message-ID: <202DD893-B152-4B38-AE9B-862E08785396@freebsd.org> In-Reply-To: <202409082111.488LBTtI074660@critter.freebsd.dk> References: <202409082111.488LBTtI074660@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 8 Sep 2024, at 22:11, Poul-Henning Kamp <phk@phk.freebsd.dk> wrote: >=20 > =EF=BB=BFWarner Losh writes: >=20 >> I did C++ in the kernel in the 4.x->7-current time frame. >=20 > The logical progression of C++ adoption would start with using a C++ > compiler as a better C compiler. I=E2=80=99m always a bit nervous about this: C=E2=80=99s struct initialiser syntax is useful for things that look like o= ptional parameters in C APIs but is invalid in C++. I believe clang and gcc s= upport it in C++ mode in some places, but I=E2=80=99m not sure where. C++ has stricter aliasing rules than C. Some things that are valid C and wil= l do the right thing with -fstrict-aliasing will incorrectly compile in C++ m= ode. C permits implicit casts from void*, C++ doesn=E2=80=99t. The last codebase I= worked on that had gone through this transition was littered with implicit c= asts which made it hard to read. At a minimum, I=E2=80=99d want to add an al= ways-inline templates wrapper around malloc that did the right thing, if not= an explicit move to new/delete. C++ places type and value names in the same namespace. There are some corner= cases where a structure and a variable have the same name and sizeof gives d= ifferent results in C and C++ modes. Compiling C as C++ will *normally* give the same output, but not always. David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202DD893-B152-4B38-AE9B-862E08785396>