Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loops try to clean up uninitialized variables #787

Closed
brson opened this issue Jul 29, 2011 · 1 comment
Closed

Loops try to clean up uninitialized variables #787

brson opened this issue Jul 29, 2011 · 1 comment

Comments

@brson
Copy link
Contributor

brson commented Jul 29, 2011

while true {
    let x = alt true {
      true { break }  
      _ { "whatever" }
    };                                                                                                                                                                    
}

Under valgrind results in:

==18230== Thread 10:
==18230== Conditional jump or move depends on uninitialised value(s)
==18230==    at 0x8048858: glue_drop2 (in /home/banderson/Dev/rust/build/test/run-pass/while-break-ref.stage1)
@msullivan
Copy link
Contributor

Oh, that's really awful. We zero out uninitialized local variables but we don't zero ones with initializers because we know that they will be initialized. However, if we break inside the initializer expression it won't get initialized or zeroed.

Argh.

@brson brson closed this as completed in c1f2394 Aug 23, 2011
keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
Fix kqueue filter consts type on NetBSD [WAS: Provide EV_SET]

Using BSD kqueue's `kevent` structure is tedious, because some BSD variants define the structure slightly differently. This forces user's code to differentiate between BSD variants and initialize `kevent` accordingly, which is annoying and error-prone.

For an example, refer to [MIO](/~https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs#L38).

This is an attempt to fix it - provide a ctor function with the same signature across BSD variants.

Is an `impl` piece for a C structure allowed in libc?

**edit:** I noticed the `kevent` function has a similar problem, maybe I should include a fix for that too...
**edit:** ^ Done
pdietl pushed a commit to pdietl/rust that referenced this issue Apr 23, 2020
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
* Fast loop affine integer calculation

* fix for step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants