Tor doesn't compile under LLVM/clang with --enable-gcc-warnings
A Tor default build builds cleanly under LLVM/clang (since bug #2689 (moved) was fixed). However, it does not build cleanly with --enable-gcc-warnings set during ./configure. This is for two reasons:
-
configure sets CFLAGS to include -Wnormalized=id -Woverride-init, which do not exist in clang 2.9
-
-Wshorten-64-to-32 is set, which triggers a warning in geoip.c
geoip.c:437:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32] ent->last_seen_in_minutes = now / 60; geoip.c:441:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32] ent->last_seen_in_minutes = now / 60;
I've attached a patch which fixes (1). If clang is being used, and the version is <= 2.9, -Wnormalized=id -Woverride-init are not set. This logic is so that if later versions of clang support these options, we won't disable them for all time without noticing.
I'm not sure if (2) is considered a bug or not. I suppose it will do the wrong thing when time_t is negative, but that was a long time ago.
This is using Tor from Git master (26009a3) on MacOS X 10.6.6.