http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60194

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> And of course also the other way round, e.g. using "%lu" or "%lz" with an
> argument which is (signed) "long".

(Ignore '%lz' that should be '%zu'.)

Thinking a bit more about it, -Wformat-unsigned (implied by -Wformat=2) is
probably the best - and ignoring the signdness for %c / character.

(Currently, the code has the following. However, the example of comment 0
doesn't trigger even with -pedantic" as it only covers pointers.)

c-family/c-format.c's check_format_types has:

      /* Don't warn about differences merely in signedness, unless
         -Wpedantic.  With -Wpedantic, warn if the type is a pointer
         target and not a character type, and for character types at
         a second level of indirection.  */
      if (TREE_CODE (wanted_type) == INTEGER_TYPE
          && TREE_CODE (cur_type) == INTEGER_TYPE
          && (!pedantic || i == 0 || (i == 1 && char_type_flag))
          && (TYPE_UNSIGNED (wanted_type)
              ? wanted_type == c_common_unsigned_type (cur_type)
              : wanted_type == c_common_signed_type (cur_type)))
        continue;

Reply via email to