Skip to content

fmt!("%?", x) is broken with x of type &[char] #4473

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
SimonSapin opened this issue Jan 13, 2013 · 2 comments
Closed

fmt!("%?", x) is broken with x of type &[char] #4473

SimonSapin opened this issue Jan 13, 2013 · 2 comments

Comments

@SimonSapin
Copy link
Contributor

Test case:

fn main() { let x: &[char] = ['a']; io::println(fmt!("%?", x)) }

Expected output: &[97]. Example output (changes on every run): &[42009435899428961].

Output from rustc --version

rustc 0.6 (09bb07b 2012-12-24 18:29:02 -0800)
host: x86_64-unknown-linux-gnu

Output with valgrind:

==12474== Memcheck, a memory error detector
==12474== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==12474== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==12474== Command: ./fmt_char_vector
==12474== 
&[461130830182350945]
==12474== 
==12474== HEAP SUMMARY:
==12474==     in use at exit: 8 bytes in 1 blocks
==12474==   total heap usage: 48 allocs, 47 frees, 1,074,617 bytes allocated
==12474== 
==12474== LEAK SUMMARY:
==12474==    definitely lost: 0 bytes in 0 blocks
==12474==    indirectly lost: 0 bytes in 0 blocks
==12474==      possibly lost: 0 bytes in 0 blocks
==12474==    still reachable: 8 bytes in 1 blocks
==12474==         suppressed: 0 bytes in 0 blocks
==12474== Rerun with --leak-check=full to see details of leaked memory
==12474== 
==12474== For counts of detected and suppressed errors, rerun with: -v
==12474== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
@jld
Copy link
Contributor

jld commented Jan 13, 2013

I found this in libcore/repr.rs:

    fn visit_char() -> bool { self.write::<uint>() }

That should probably be u32.

@brson
Copy link
Contributor

brson commented Jan 14, 2013

Fixed.

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

3 participants