Some fun with -O2

Thierry Thomas thierry at freebsd.org
Thu Jan 14 11:25:34 UTC 2021


Let´s check a small C program, check_mktime.c, fetchable from
<https://people.freebsd.org/~thierry/check_mktime.c>.

$CC -o check_mktime -O2 check_mktime.c
./check_mktime

It is OK with clang90.
It loops forever with gcc9, gcc10, clang10 and clang11,
but OK without -O2.

It is part of the configure script of ports/math/oleo, and I guess that
the same part could be found in other configure scripts.

Note a similar program is part of glibc: see
<https://code.woboq.org/userspace/glibc/time/tst-mktime2.c.html>.

Regards.
-- 
Th. Thomas.


More information about the freebsd-hackers mailing list