r/cpp • • May 12 '15

Criticizing the Rust Language, and Why C/C++ Will Never Die

http://www.viva64.com/en/b/0324/
0 Upvotes

61 comments sorted by

View all comments

Show parent comments

1

u/kouteiheika May 13 '15 edited May 13 '15

Result<T, Err> is only the size of the larger variant + 1, not their sum.

This is incorrect; due to padding it most likely going to be more than just + 1, e.g. the size of Result< u64, u8 > is 16, not 9.

I do wonder if there is any point in actually having this padded; it can waste a lot of memory (and trash the cache) while supposedly there is no performance hit on modern hardware for unaligned memory accesses.

1

u/Rusky May 13 '15

Sure, but it's not T+Err either, which was my main point.