Skip to content

Debug asserts aren't enabled by default in optimized build #17124

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

Closed
wants to merge 65 commits into from
Closed

Debug asserts aren't enabled by default in optimized build #17124

wants to merge 65 commits into from

Conversation

gamazeps
Copy link
Contributor

@gamazeps gamazeps commented Sep 9, 2014

fixes #17081

#[macro_export]
macro_rules! debug_assert(
($(a:tt)*) => ({
if cfg!(not(ndebug)) {
if (cfg!(not(optimize)) && cfg!(not(ndebug)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, where does the optimize configuration get defined?

fn main() {
    println!("{}", cfg!(optimize));
}

prints false with or without -O.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was defined in https://github.com/rust-lang/rust/blob/master/src/librustc/driver/config.rs#L781 but it seems that I was wrong.

I'll look into it, sorry if my pr was flawed :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if my pr was flawed :/

Don't worry. 😄

Felix Raimundo and others added 26 commits September 13, 2014 00:10
 - Ensures the propagated negation sign is properly utilized during type
   checking.
 - Removed redundant type checking, specifically regarding the out of bounds checking
   on a bounded type.
 - Closes #16684
This code used to produce an ICE on the definition of trait Bar
with the following message:

Type parameter out of range when substituting in region 'a (root
type=fn(Self) -> 'astr) (space=FnSpace, index=0)

Closes #16218.
This test verifies that casting from the same lifetime on a value
to the same lifetime on a trait succeeds. Closes #10766.
Breaks `iterate(f, seed)`, use `iterate(seed, f)` instead.
The convention is to have the closure last.

Closes #17066.

[breaking-change]
The performance hit from these checks is significant, but unoptimized
builds are already incredibly slow. Enabling these checks results in
better test coverage since there are bots doing unoptimized builds, and
the cost is relatively small in the context of an unoptimized build.
This also allows using `JEMALLOC_FLAGS` to override the default
configure flags.
Other languages may not want to have a leading #-line get stripped.
Win32/WinSock APIs never call WSASetLastError() with WSAEINTR
unless a programmer specifically cancels the ongoing blocking call by
a deprecated WinSock1 API WSACancelBlockingCall().
So the errno check was simply removed and retry() became an id function
on Windows.
Note: Windows' equivalent of SIGINT is always handled in a separate thread:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682541%28v=vs.85%29.aspx
"CTRL+C and CTRL+BREAK Signals"

Also, incidentally rename a type parameter and clean up some module imports.
This code used to produce the following ICE:

   error: internal compiler error: get_unique_type_id_of_type() -
   unexpected type: closure,
   ty_unboxed_closure(syntax::ast::DefId{krate: 0u32, node: 66u32},
   ReScope(63u32))

This is a regression test for issue #17021.
This uses a bitwise mask to ensure that there's no bounds checking for
the array accesses when generating the next random number. This isn't
costless, but the single instruction is nothing compared to the branch.

A `debug_assert` for "bounds check" is preserved to ensure that
refactoring doesn't accidentally break it (i.e. create values of `cnt`
that are out of bounds with the masking causing it to silently wrap-
around).

Before:

    test test::rand_isaac   ... bench: 990 ns/iter (+/- 24) = 808 MB/s
    test test::rand_isaac64 ... bench: 614 ns/iter (+/- 25) = 1302 MB/s

After:

    test test::rand_isaac   ... bench: 877 ns/iter (+/- 134) = 912 MB/s
    test test::rand_isaac64 ... bench: 470 ns/iter (+/- 30) = 1702 MB/s

(It also removes the unsafe code in Isaac64Rng.next_u64, with a *gain*
in performance; today is a good day.)
itself.

This breaks code like:

    for &x in my_vector.iter() {
        my_vector[2] = "wibble";
        ...
    }

Change this code to not invalidate iterators. For example:

    for i in range(0, my_vector.len()) {
        my_vector[2] = "wibble";
        ...
    }

The `for-loop-does-not-borrow-iterators` test for #8372 was incorrect
and has been removed.

Closes #16820.

[breaking-change]
This breaks code that uses the `..xs` form anywhere but at the end of a
slice. For example:

    match foo {
        [ 1, ..xs, 2 ]
        [ ..xs, 1, 2 ]
    }

Add the `#![feature(advanced_slice_patterns)]` gate to reenable the
syntax.

RFC #54.

Closes #16951.

[breaking-change]
There isn't a good way to fit this in, so let's just not
mention it.

Fixes #16792.
instead of prefix `..`.

This breaks code that looked like:

    match foo {
        [ first, ..middle, last ] => { ... }
    }

Change this code to:

    match foo {
        [ first, middle.., last ] => { ... }
    }

RFC #55.

Closes #16967.

[breaking-change]
alexcrichton and others added 28 commits September 13, 2014 00:16
This allows code to access the fields of tuples and tuple structs:

    let x = (1i, 2i);
    assert_eq!(x.1, 2);

    struct Point(int, int);
    let origin = Point(0, 0);
    assert_eq!(origin.0, 0);
    assert_eq!(origin.1, 0);
…detecting them in resolve. This simplifies logic elsewhere in the compiler. cc #5527
I missed some annotations, and some were in a different style.
Instead of `extern crate foo = bar`, write `extern crate bar as foo`.
Instead of `extern crate baz = "quux"`, write `extern crate "quux" as
baz`.

Closes #16461.

[breaking-change]
Previously, some parts of this optimization were impossible because the
alignment passed to the free function was not correct. That was fully
fixed by #17012.

Closes #17092
…bin/) to PATH during linking,

so that rustc can invoke them.
gcc, ld, ar, dlltool, windres go into $(RUST)/bin/rustlib/<triple>/bin/
platform libraries and startup objects got into $(RUST)/bin/rustlib/<triple>/lib/
The Guide isn't 100% perfect, but it's basically complete. It's
certainly better than the tutorial is. Time to start pointing more
people its way.

I also just made it consistent to call all things 'guides' rather than
tutorials.

Fixes #9874. This is the big one.

And two bugs that just go away.

Fixes #14503.
Fixes #15009.
@alexcrichton
Copy link
Member

Closing to see if this unsticks bors

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

Successfully merging this pull request may close these issues.

debug_assert and debug logging shouldn't be enabled by default in optimized builds