NetBSD/external/gpl3/gcc
christos 68ac9d1eae LIBISMODULE should be yes or no... 2024-04-04 23:54:17 +00:00
..
dist add some missing alignment. 2024-02-25 01:12:16 +00:00
lib LIBISMODULE should be yes or no... 2024-04-04 23:54:17 +00:00
usr.bin mknative-gcc for most targets and enabling isl. 2024-02-25 01:20:55 +00:00
Makefile
Makefile.autobuild_h various updates to build native GCC 12. 2023-08-01 05:57:53 +00:00
Makefile.gcc_path
Makefile.hooks various updates to build native GCC 12. 2023-08-01 05:57:53 +00:00
Makefile.version_h various updates to build native GCC 12. 2023-08-01 05:57:53 +00:00
README.gcc12 note as being equally function on riscv32. 2023-10-22 00:09:20 +00:00
README.warnings gcc/README.warnings: Nix trailing whitespace. 2023-08-08 11:50:22 +00:00
gcc2gcc.old
gcc2netbsd don't elide fortran components. we'd like to revive g77-as-gfortran. 2020-06-02 08:03:59 +00:00

README.warnings

$NetBSD: README.warnings,v 1.5 2023/08/08 11:50:22 riastradh Exp $

What to do about GCC warnings and NetBSD.


New GCC releases always come with a host of new warnings and
each new warning can find real bugs, find odd code, or simply
be a pain of new useless warnings, or all three and more.

As each warning has its own set of issues they each have their
own section and it is expected that this document will be
modified for updates to warnings and new warnings.


<bsd.own.mk> provides several variables for use in Makefiles:
   COPTS.foo.c += ${CC_WNO_FORMAT_TRUNCATION}
   COPTS.foo.c += ${CC_WNO_FORMAT_OVERFLOW}
   COPTS.foo.c += ${CC_WNO_STRINGOP_OVERFLOW}
   COPTS.foo.c += ${CC_WNO_STRINGOP_TRUNCATION}
   COPTS.foo.c += ${CC_WNO_CAST_FUNCTION_TYPE}
   COPTS.foo.c += ${CC_WNO_IMPLICIT_FALLTHROUGH}
   COPTS.foo.c += ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
   COPTS.foo.c += ${CC_WNO_MAYBE_UNINITIALIZED}
   COPTS.foo.c += ${CC_WNO_RETURN_LOCAL_ADDR}
   COPTS.foo.c += ${CC_WNO_MISSING_TEMPLATE_KEYWORD}
   COPTS.foo.c += ${CC_WNO_STRINGOP_OVERREAD}
   COPTS.foo.c += ${CC_WNO_REGISTER}
   COPTS.foo.c += ${CC_WNO_ARRAY_BOUNDS}


new GCC 12 warnings:

  -Wno-missing-template-keyword

      This warning trips on older C++ code, and should only be applyed to 3rd
      party code.

      bsd.own.mk variable: ${CC_WNO_MISSING_TEMPLATE_KEYWORD}

  -Wno-stringop-overread

      This warning triggers when array bounds appear to be exceeded.  There
      maybe some bugs related to this warning in GCC 12.

      bsd.own.mk variable: ${CC_WNO_STRINGOP_OVERREAD}

  -Wno-register

      This warning triggers in C++17 mode where 'register' has been removed,
      and should only be applied to 3rd party code.

      bsd.own.mk variable: ${CC_WNO_REGISTER}

  -Wno-array-bounds

      This warning triggers with a number of code issues that tend to be real
      problem but require careful adjustments to fix properly, when there are
      platform related accesses beyond the immediately size and address of
      known variables (real bugs to fix), but also may trigger when passing
      C arrays vs C pointers to functions, often incorrectly.  See
	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878

      bsd.own.mk variable: ${CC_WNO_ARRAY_BOUNDS}


new GCC 10 warnings:

  GCC 10 switched the default from "-fcommon" to "-fno-common",
  which can cause multiply defined symbol issues.  Ideally we
  fix all of these, but "-fcommon" can be used otherwise.

  -Wno-maybe-uninitialized

      This warning was introduced in an ancient GCC but was
      significantly enhanced in GCC 10, unfortunately, many of
      the new instances are incorrect.

      bsd.own.mk variable: ${CC_WNO_MAYBE_UNINITIALIZED}

  -Wno-return-local-addr

      This warning was introduced in GCC 5 and was enhanced in GCC
      10.  Unfortunately, the new instances are failing to correctly
      analyze code flow and miss that most of the are handled.

      bsd.own.mk variable: ${CC_WNO_RETURN_LOCAL_ADDR}


new GCC 9 warnings:

  -Wno-address-of-packed-member

      This warning was introduced in GCC 8.
      This warning is similar to -Wformat-truncation, but for the
      general family of string functions (str*(), etc.), and has
      similar issues of false positives.

      bsd.own.mk variable: ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}


new GCC 8 warnings:

  -Wstringop-truncation

      This warning was introduced in GCC 8.
      This warning is similar to -Wformat-truncation, but for the
      general family of string functions (str*(), etc.), and has
      similar issues of false positives.

      bsd.own.mk variable: ${CC_WNO_STRINGOP_TRUNCATION}


  -Wcast-function-type

      This warning was introduced in GCC 8.
      This warning can find real problems.  Most instances are
      false positives, and hopefully this warning will become
      more useful in the future.  See __FPTRCAST().

      bsd.own.mk variable: ${CC_WNO_CAST_FUNCTION_TYPE}


new GCC 7 warnings:

  -Wstringop-overflow

      This warning was introduced in GCC 7.
      This warning can find issues where source length is
      passed as destination length (eg, strncpy() where the
      length is strlen(src)) that are potential buffer overflow
      cases and should always be inspected, but false positives
      are also seen.

      bsd.own.mk variable: ${CC_WNO_STRINGOP_OVERFLOW}


  -Wformat-truncation

    This warning was introduced in GCC 7.
    This warning has many false positives where truncation is
    either expected or unavoidable, but also finds several real
    code bugs.

    Code should always be manually inspected for this warning
    as it does pick up real issues.

    bsd.own.mk variable: ${CC_WNO_FORMAT_TRUNCATION}


  -Wformat-overflow

    This warning was introduced in GCC 7.
    This warning typically identifies a real problem, but it may
    fail to notice the code handles this case.

    Code should always be manually inspected for this warning
    as it does pick up real issues.

    bsd.own.mk variable: ${CC_WNO_FORMAT_OVERFLOW}


  -Wimplicit-fallthrough

    This warning was introduced in GCC 7.
    This warning has many false positives in GCC 7, and many are
    fixed in newer GCC 10.  Old uses should be checked occasionally.

    Code should always be manually inspected for this warning
    as it does pick up real issues.

    bsd.own.mk variable: ${CC_WNO_IMPLICIT_FALLTHROUGH}