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: > > Warner Losh writes: > >> I did C++ in the kernel in the 4.x->7-current time frame. > > The logical progression of C++ adoption would start with using a C++ > compiler as a better C compiler. I’m always a bit nervous about this: C’s struct initialiser syntax is useful for things that look like optional parameters in C APIs but is invalid in C++. I believe clang and gcc support it in C++ mode in some places, but I’m not sure where. C++ has stricter aliasing rules than C. Some things that are valid C and will do the right thing with -fstrict-aliasing will incorrectly compile in C++ mode. C permits implicit casts from void*, C++ doesn’t. The last codebase I worked on that had gone through this transition was littered with implicit casts which made it hard to read. At a minimum, I’d want to add an always-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 different 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>
