sheredom / utest.h

🧪 single header unit testing framework for C and C++
The Unlicense
845 stars 59 forks source link

error: conversion from ‘size_t’ compiling with -Werror=conversion #101

Closed jcorporation closed 2 years ago

jcorporation commented 2 years ago

Thanks for this handy unit test framework! I use it in my mpdclient project myMPD.

Version: master Toolchain: gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1) Target: x86_64-linux-gnu

Full error:

/dist/utest/utest.h: In function ‘utest_main’:
/dist/utest/utest.h:1212:35: error: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘utest_uint32_t’ {aka ‘const unsigned int’} may change value [-Werror=conversion]
 1212 |       const utest_uint32_t next = ((word >> 22u) ^ word) % index;
sheredom commented 2 years ago

Interesting - its because index is size_t. I legit have no idea why this wasn't flagged with the existing testing!

sheredom commented 2 years ago

I think I fixed this in #103!

jcorporation commented 2 years ago

I could test it now, it is fixed, thanks!