3 ms·
Neither of those things are undefined behavior, but gcc with -Wextra already warns about both: warn.c:6:21: warning: comparison of integer expressions of d
by moefh 2y ago
Neither of those things are undefined behavior, but gcc with -Wextra already warns about both:
warn.c:6:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | for (int i = 0; i < n; i++)
| ^
warn.c:10:36: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
10 | for (size_t i = sizeof(var)-1; i >= 0; --i)
| ^~