Re: [TECH TOPIC] Rust for Linux

Alexey Dobriyan
2021-07-08T06:26:25Z

On Wed, Jul 07, 2021 at 11:57:19AM -0700, Linus Torvalds wrote:
> On Tue, Jul 6, 2021 at 7:41 PM Bart Van Assche <bvanassche@acm.org> wrote:
> >
> > As a sidenote, I'm surprised that C++ is not supported for Linux kernel
> > code since C++ supports multiple mechanisms [..]
>
> You'd have to get rid of some of the complete garbage from C++ for it
> to be usable.
>
> One of the trivial ones is "new" - not only is it a horribly stupid
> namespace violation, but it depends on exception handling that isn't
> viable for the kernel, so it's a namespace violation that has no
> upsides, only downsides.

"new" is such a non-problem.

"Allocating" new simply doesn't work by default:

undefined reference to `operator new(unsigned long)'

Class level operator new is deal with by "-fcheck-new" so that constructors
don't run if allocation fails, then the pointer is checked as usual.

Placement "new" can be disabled completely if needed.

> Could we fix it with some kind of "-Dnew=New" trickery?

No, developers will type "new_" and that's basically it.