GithubHelp home page GithubHelp logo

Comments (4)

Matthias247 avatar Matthias247 commented on September 26, 2024

Thanks for mentioning it. I think when I initially wrote it I also didn't like it too much because of how the code looks like. But I don't think anything is undefined here, since the length is not part of the uninitialized memory but kept by the compiler separately and then inserted into the DST.

I actually hope to replace all of those things with const generics once stable, which also should improve the code for these ringbuffers.

from futures-intrusive.

sfackler avatar sfackler commented on September 26, 2024

since the length is not part of the uninitialized memory but kept by the compiler separately and then inserted into the DST.

Again, the data access isn't what's relevant - the fact that the reference was created in the first place is.

cc @RalfJung am I misinterpreting here?

from futures-intrusive.

Matthias247 avatar Matthias247 commented on September 26, 2024

Changed in 3b15bf1

A where A: RealArray<MaybeUninit>

this wasn't great, since it would have required users to pass MaybeUninit as a parameter to channel types - at least that's how I understood it. So I went for the associated constant version.

I still can't see how the reference would have been harmful since it is not really accessed and everything was already in an unsafe block. However I see why the rule is in general unsafe guidelines since the actual behavior is hard to describe.

from futures-intrusive.

RalfJung avatar RalfJung commented on September 26, 2024

FWIW, @sfackler is right. Quoting from the reference: UB occurs when...

Producing an invalid value, even in private fields and locals.
"Producing" a value happens any time a value is assigned to or read from a place, passed to a function/primitive operation or returned from a function/primitive operation.
The following values are invalid (at their respective type):
[...] A reference or Box<T> that is dangling, unaligned, or points to an invalid value.

The reason why even "unused" values need to be valid is that there are some very important compiler optimizations, such as hoisting operations out of loops, that can make unused variables used. (I have a blog post planned for that, but at my current schedule that's not going to happen this year...)

from futures-intrusive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.