Better warnings for cross-type comparisons

Set the stacklevel when warning so there's a better chance of warning
about the correct caller. Also log a complete stacktrace.