Yves Posted April 27, 2011 Report Share Posted April 27, 2011 (edited) HiRunning test with runtimechecks enabled results in an error:-------Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example: char c = (i & 0xFF);Changing the code in this way will not affect the quality of the resulting optimized code.-------I've changed a few lines in tex_dds.cpp to work around the error. Before: static inline size_t access_bit_tbl64(u64 tbl, size_t idx, size_t bit_width) { size_t val = (size_t)(tbl >> (idx*bit_width)); val &= bit_mask<u64>(bit_width); return val; }After: static inline size_t access_bit_tbl64(u64 tbl, size_t idx, size_t bit_width) { size_t val = (tbl >> (idx*bit_width)) & bit_mask<u64>(bit_width); return val; }or probably even: static inline size_t access_bit_tbl64(u64 tbl, size_t idx, size_t bit_width) { return (tbl >> (idx*bit_width)) & bit_mask<u64>(bit_width); }The same should most likely be done with the function access_bit_tbl.It simply removes the need for a cast and makes it a bit less readable .That's the only problem I've detected so far with runtimechecking.What do you think? Is that right or did I miss something? Edited April 27, 2011 by Yves Quote Link to comment Share on other sites More sharing options...
janwas Posted April 28, 2011 Report Share Posted April 28, 2011 Hi and thanks for looking into this!I've just committed a fix based upon your first proposal (it's sometimes nice to have a separate local variable to display its value when debugging - more convenient than shift+F11 and adding a watch on RAX).While at it, I've combined both functions into a template to avoid duplication. Quote Link to comment Share on other sites More sharing options...
Yves Posted April 28, 2011 Author Report Share Posted April 28, 2011 Good, thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.