Search notes:

gcc -W

-Wdeprecated-declaration

With the option -Wdeprecated-declaration in effect, the compiler will warn about the use of deprecated variables, structs and functions.
These are declared as deprecated with __attribute__((deprecated)).

-Wfloat-equal

//
//      -Wfloat-equal:
//        Warn if two floating-point numbers are compared.
//
//  gcc -Wfloat-equal float-equal.c
//

#include <stdio.h>

int main() {

  float f1 = 4.2549342;
  float f2 = 4.2549343;

  if (f1 == f2) {
    printf("f1 == f2\n");
  }
}
Github repository about-gcc, path: /options/W/float-equal.c

-Winit-self

//
//   -Winit-self
//        Warn about variables that are initialized with themselves.
//        Option can only be used together with -Wuninitialized.
//
//   gcc -Wuninitialized -Winit-self init-self.c
//

#include <stdio.h>
int main() {

  int i = i;

  printf("i=%d\n", i);

}
Github repository about-gcc, path: /options/W/init-self.c

-Wshadow

//
//     -Wshadow:
//      Warn about local variables shadowing another variable.
//
// gcc -Wshadow shadow.c

#include <stdio.h>

int main() {

  int i = 42;

  if (i == 42) {

    printf("i=%d\n", i);
    int i = 49;
    printf("i=%d\n", i);

  }
}
Github repository about-gcc, path: /options/W/shadow.c

-Wundef

//
//   -Wundef:
//      Warn if an undefined macro is evaluated
//      in an #if construct.
//      

#include <stdio.h>


int main() {

#if UNDEFINED_MACRO > 5
  printf("UNDEFINED_MACRO is defined!!!\n");
#endif
  printf("Hello world\n");

}
Github repository about-gcc, path: /options/W/undef.c

-Wpedantic

-Wpedantic is equivalent to -pedantic.

-Wunreachable-code

//
//   -Wunreachable-code was supposed to warn if code was unreachable.
//    It functionality, not the warning, had been removed:
//
//      https://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html
//

#include <stdio.h>

void f() {
  printf("unreachable");
}

int main() {

  printf("1\n");
  return 0;
  printf("2\n");

}
Github repository about-gcc, path: /options/W/unreachable-code.c

List of warning related options

A list of warning related options can be produced with gcc --help=warnings:
--all-warnings Same as -Wall.
--extra-warnings Same as -Wextra.
-W This switch is deprecated in favor of -Wextra (which does the same).
-Wabi Warn about things that will change when compiling with an ABI-compliant compiler.
-Wabi-tag Warn if a subobject has an abi_tag attribute that the complete object type does not have.
-Wabi= Warn about things that change between the current -fabi-version and the specified version.
-Wabsolute-value Warn on suspicious calls of standard functions computing absolute values.
-Waddress Warn about suspicious uses of memory addresses.
-Waddress-of-packed-member Warn when the address of packed member of struct or union is taken.
-Waggregate-return Warn about returning structures, unions or arrays.
-Waggressive-loop-optimizations Warn if a loop with constant number of iterations triggers undefined behavior.
-Waliasing Warn about possible aliasing of dummy arguments.
-Walign-commons Warn about alignment of COMMON blocks.
-Waligned-new=[none|global|all] Warn even if 'new' uses a class member allocation function.
-Wall Enable most warning messages.
-Walloc-size-larger-than=<bytes> Warn for calls to allocation functions that attempt to allocate objects larger than the specified number of bytes.
-Walloc-zero Warn for calls to allocation functions that specify zero bytes.
-Walloca Warn on any use of alloca.
-Walloca-larger-than=<number> Warn on unbounded uses of alloca, and on bounded uses of alloca whose bound can be larger than <number> bytes.
-Wampersand Warn about missing ampersand in continued character constants.
-Wanalyzer-double-fclose Warn about code paths in which a stdio FILE can be closed more than once.
-Wanalyzer-double-free Warn about code paths in which a pointer can be freed more than once.
-Wanalyzer-exposure-through-output-file Warn about code paths in which sensitive data is written to a file.
-Wanalyzer-file-leak Warn about code paths in which a stdio FILE is not closed.
-Wanalyzer-free-of-non-heap Warn about code paths in which a non-heap pointer is freed.
-Wanalyzer-malloc-leak Warn about code paths in which a heap-allocated pointer leaks.
-Wanalyzer-null-argument Warn about code paths in which NULL is passed to a must-not-be-NULL function argument.
-Wanalyzer-null-dereference Warn about code paths in which a NULL pointer is dereferenced.
-Wanalyzer-possible-null-argument Warn about code paths in which a possibly-NULL value is passed to a must-not-be-NULL function argument.
-Wanalyzer-possible-null-dereference Warn about code paths in which a possibly-NULL pointer is dereferenced.
-Wanalyzer-stale-setjmp-buffer Warn about code paths in which a longjmp rewinds to a jmp_buf saved in a stack frame that has returned.
-Wanalyzer-tainted-array-index Warn about code paths in which an unsanitized value is used as an array index.
-Wanalyzer-too-complex Warn if the code is too complicated for the analyzer to fully explore.
-Wanalyzer-unsafe-call-within-signal-handler Warn about code paths in which an async-signal-unsafe function is called from a signal handler.
-Wanalyzer-use-after-free Warn about code paths in which a freed value is used.
-Wanalyzer-use-of-pointer-in-stale-stack-frame Warn about code paths in which a pointer to a stale stack frame is used.
-Warith-conversion Warn if conversion of the result of arithmetic might change the value even though converting the operands cannot.
-Warray-bounds Warn if an array is accessed out of bounds.
-Warray-bounds=<0,2> Warn if an array is accessed out of bounds.
-Warray-temporaries Warn about creation of array temporaries.
-Wassign-intercept Warn whenever an Objective-C assignment is being intercepted by the garbage collector.
-Wattribute-alias Warn about type safety and similar errors and mismatches in declarations with alias attributes. Same as -Wattribute-alias=.
-Wattribute-alias=<0,2> Warn about type safety and similar errors and mismatches in declarations with alias attributes.
-Wattribute-warning Warn about uses of __attribute__((warning)) declarations.
-Wattributes Warn about inappropriate attribute usage.
-Wbad-function-cast Warn about casting functions to incompatible types.
-Wbool-compare Warn about boolean expression compared with an integer value different from true/false.
-Wbool-operation Warn about certain operations on boolean expressions.
-Wbuiltin-declaration-mismatch Warn when a built-in function is declared with the wrong signature.
-Wbuiltin-macro-redefined Warn when a built-in preprocessor macro is undefined or redefined.
-Wc++-compat Warn about C constructs that are not in the common subset of C and C++.
-Wc++0x-compat Same as -Wc++11-compat.
-Wc++11-compat Warn about C++ constructs whose meaning differs between ISO C++ 1998 and ISO C++ 2011.
-Wc++14-compat Warn about C++ constructs whose meaning differs between ISO C++ 2011 and ISO C++ 2014.
-Wc++17-compat Warn about C++ constructs whose meaning differs between ISO C++ 2014 and ISO C++ 2017.
-Wc++1z-compat Same as -Wc++17-compat.
-Wc++20-compat Warn about C++ constructs whose meaning differs between ISO C++ 2017 and ISO C++ 2020.
-Wc++2a-compat Same as -Wc++20-compat.
-Wc-binding-type Warn if the type of a variable might be not interoperable with C.
-Wc11-c2x-compat Warn about features not present in ISO C11, but present in ISO C2X.
-Wc90-c99-compat Warn about features not present in ISO C90, but present in ISO C99.
-Wc99-c11-compat Warn about features not present in ISO C99, but present in ISO C11.
-Wcannot-profile Warn when profiling instrumentation was requested, but could not be applied to a certain function.
-Wcast-align Warn about pointer casts which increase alignment.
-Wcast-align=strict Warn about pointer casts which increase alignment.
-Wcast-function-type Warn about casts between incompatible function types.
-Wcast-qual Warn about casts which discard qualifiers.
-Wcast-result Warn about casts that will produce a null result.
-Wcatch-value Warn about catch handlers of non-reference type. Same as -Wcatch-value=.
-Wcatch-value=<0,3> Warn about catch handlers of non-reference type.
-Wchar-subscripts Warn about subscripts whose type is char.
-Wcharacter-truncation Warn about truncated character expressions.
-Wchkp Removed in GCC 9. This switch has no effect.
-Wclass-conversion Warn when a conversion function will never be called due to the type it converts to.
-Wclass-memaccess Warn for unsafe raw memory writes to objects of class types.
-Wclobbered Warn about variables that might be changed by longjmp or vfork.
-Wcomma-subscript Warn about uses of a comma operator within a subscripting expression.
-Wcomment Warn about possibly nested block comments, and C++ comments spanning more than one physical line.
-Wcomments Synonymfor/same as -Wcomment
-Wcompare-reals Warn about equality comparisons involving REAL or COMPLEX expressions.
-Wconditionally-supported Warn for conditionally-supported constructs.
-Wconversion Warn for implicit type conversions that may change a value.
-Wconversion-extra Warn about most implicit conversions.
-Wconversion-null Warn for converting NULL from/to a non-pointer type.
-Wcoverage-mismatch Warn in case profiles in -fprofile-use do not match.
-Wcpp Warn when a #warning directive is encountered.
-Wctor-dtor-privacy Warn when all constructors and destructors are private.
-Wdangling-else Warn about dangling else.
-Wdate-time Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage.
-Wdeclaration-after-statement Warn when a declaration is found after a statement.
-Wdelete-incomplete Warn when deleting a pointer to incomplete type.
-Wdelete-non-virtual-dtor Warn about deleting polymorphic objects with non-virtual destructors.
-Wdeprecated Warn if a deprecated compiler feature, class, method, or field is used.
-Wdeprecated-copy Mark implicitly-declared copy operations as deprecated if the class has a user-provided copy operation.
-Wdeprecated-copy-dtor Mark implicitly-declared copy operations as deprecated if the class has a user-provided copy operation or destructor.
-Wdeprecated-declarations Warn about uses of __attribute__((deprecated)) declarations.
-Wdesignated-init Warn about positional initialization of structs requiring designated initializers.
-Wdisabled-optimization Warn when an optimization pass is disabled.
-Wdiscarded-array-qualifiers Warn if qualifiers on arrays which are pointer targets are discarded.
-Wdiscarded-qualifiers Warn if type qualifiers on pointers are discarded.
-Wdiv-by-zero Warn about compile-time integer division by zero.
-Wdo-subscript Warn about possibly incorrect subscripts in do loops.
-Wdouble-promotion Warn about implicit conversions from "float" to "double".
-Wduplicate-decl-specifier Warn when a declaration has duplicate const, volatile, restrict or _Atomic specifier.
-Wduplicated-branches Warn about duplicated branches in if-else statements.
-Wduplicated-cond Warn about duplicated conditions in an if-else-if chain.
-Weffc++ Warn about violations of Effective C++ style rules.
-Wempty-body Warn about an empty body in an if or else statement.
-Wendif-labels Warn about stray tokens after #else and #endif.
-Wenum-compare Warn about comparison of different enum types.
-Wenum-conversion Warn about implicit conversion of enum types.
-Werror-implicit-function-declaration This switch is deprecated; use -Werror=implicit-function-declaration instead. Same as -Werror=.
-Wexpansion-to-defined Warn if defined is used outside #if.
-Wextra Print extra (possibly unwanted) warnings.
-Wextra-semi Warn about semicolon after in-class function definition.
-Wfloat-conversion Warn for implicit type conversions that cause loss of floating point precision.
-Wfloat-equal Warn if testing floating point numbers for equality.
-Wformat Warn about printf/scanf/strftime/strfmon format string anomalies. Same as -Wformat=.
-Wformat-contains-nul Warn about format strings that contain NUL bytes.
-Wformat-diag Warn about GCC format strings with strings unsuitable for diagnostics.
-Wformat-extra-args Warn if passing too many arguments to a function for its format string.
-Wformat-nonliteral Warn about format strings that are not literals.
-Wformat-overflow<0,2> Warn about function calls with format strings that write past the end of the destination region. Same as -Wformat-overflow=1 or -Wformat-overflow= .
-Wformat-overflow=<0,2> Warn about function calls with format strings that write past the end of the destination region.
-Wformat-security Warn about possible security problems with format functions.
-Wformat-signedness Warn about sign differences with format functions.
-Wformat-truncation Warn about calls to snprintf and similar functions that truncate output. Same as -Wformat-truncation=1 or-Wformat-truncation=.
-Wformat-truncation=<0,2> Warn about calls to snprintf and similar functions that truncate output.
-Wformat-y2k Warn about strftime formats yielding 2-digit years.
-Wformat-zero-length Warn about zero-length formats.
-Wformat=<0,2> Warn about printf/scanf/strftime/strfmon format string anomalies.
-Wframe-address Warn when __builtin_frame_address or __builtin_return_address is used unsafely.
-Wframe-larger-than=<byte-size> Warn if a function's stack frame requires in excess of <byte-size>.
-Wfree-nonheap-object Warn when attempting to free a non-heap object.
-Wfunction-elimination Warn about function call elimination.
-Whsa Warn when a function cannot be expanded to HSAIL.
-Wif-not-aligned Warn when the field in a struct is not aligned.
-Wignored-attributes Warn whenever attributes are ignored.
-Wignored-qualifiers Warn whenever type qualifiers are ignored.
-Wimplicit Warn about implicit declarations.
-Wimplicit-fallthrough Same as -Wimplicit-fallthrough=3 (or, in negated form, -Wimplicit-fallthrough=0).
-Wimplicit-fallthrough=<0,5> Warn when a switch case falls through.
-Wimplicit-function-declaration Warn about implicit function declarations.
-Wimplicit-int Warn when a declaration does not specify a type.
-Wimplicit-interface Warn about calls with implicit interface.
-Wimplicit-procedure Warn about called procedures not explicitly declared.
-Winaccessible-base Warn when a base is inaccessible in derived due to ambiguity.
-Wincompatible-pointer-types Warn when there is a conversion between pointers that have incompatible types.
-Winherited-variadic-ctor Warn about C++11 inheriting constructors when the base has a variadic constructor.
-Winit-list-lifetime Warn about uses of std::initializer_list that can result in dangling pointers.
-Winit-self Warn about variables which are initialized to themselves.
-Winline Warn when an inlined function cannot be inlined.
-Wint-conversion Warn about incompatible integer to pointer and pointer to integer conversions.
-Wint-in-bool-context Warn for suspicious integer expressions in boolean context.
-Wint-to-pointer-cast Warn when there is a cast to a pointer from an integer of a different size.
-Winteger-division Warn about constant integer divisions with truncated results.
-Wintrinsic-shadow Warn if a user-procedure has the same name as an intrinsic.
-Wintrinsics-std Warn on intrinsics not part of the selected standard.
-Winvalid-memory-model Warn when an atomic memory model parameter is known to be outside the valid range.
-Winvalid-offsetof Warn about invalid uses of the "offsetof" macro.
-Winvalid-pch Warn about PCH files that are found but not used.
-Wjump-misses-init Warn when a jump misses a variable initialization.
-Wlarger-than- Same as -Wlarger-than=.
-Wlarger-than=<byte-size> Warn if an object's size exceeds <byte-size>.
-Wline-truncation Warn about truncated source lines.
-Wliteral-suffix Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore.
-Wlogical-not-parentheses Warn when logical not is used on the left hand side operand of a comparison.
-Wlogical-op Warn when a logical operator is suspiciously always evaluating to true or false.
-Wlong-long Do not warn about using "long long" when -pedantic.
-Wlto-type-mismatch During link time optimization warn about mismatched types of global declarations.
-Wmain Warn about suspicious declarations of "main".
-Wmaybe-uninitialized Warn about maybe uninitialized automatic variables.
-Wmemset-elt-size Warn about suspicious calls to memset where the third argument contains the number of elements not multiplied by the element size.
-Wmemset-transposed-args Warn about suspicious calls to memset where the third argument is constant literal zero and the second is not.
-Wmisleading-indentation Warn when the indentation of the code does not reflect the block structure.
-Wmismatched-tags Warn when a class is redeclared or referenced using a mismatched class-key.
-Wmissing-attributes Warn about declarations of entities that may be missing attributes that related entities have been declared with.
-Wmissing-braces Warn about possibly missing braces around initializers.
-Wmissing-declarations Warn about global functions without previous declarations.
-Wmissing-field-initializers Warn about missing fields in struct initializers.
-Wmissing-format-attribute Same as -Wsuggest-attribute=format.
-Wmissing-include-dirs Warn about user-specified include directories that do not exist.
-Wmissing-noreturn Same as -Wsuggest-attribute=noreturn.
-Wmissing-parameter-type Warn about function parameters declared without a type specifier in K&R-style functions.
-Wmissing-profile Warn in case profiles in -fprofile-use do not exist.
-Wmissing-prototypes Warn about global functions without prototypes.
-Wmultichar Warn about use of multi-character character constants.
-Wmultiple-inheritance Warn on direct multiple inheritance.
-Wmultistatement-macros Warn about unsafe macros expanding to multiple statements used as a body of a clause such as if, else, while, switch, or for.
-Wnamespaces Warn on namespace definition.
-Wnarrowing Warn about narrowing conversions within { } that are ill-formed in C++11.
-Wnested-externs Warn about "extern" declarations not at file scope.
-Wno-alloc-size-larger-than Disable Walloc-size-larger-than= warning. Equivalent to Walloc-size-larger-than=<SIZE_MAX> or larger. Same as -Walloc-size-larger-than=.
-Wno-alloca-larger-than Disable -Walloca-larger-than= warning. Equivalent to -Walloca-larger-than=<SIZE_MAX> or larger. Same as -Walloca-larger-than=.
-Wno-frame-larger-than Disable -Wframe-larger-than= warning. Equivalent to -Wframe-larger-than=<SIZE_MAX> or larger. Same as -Wframe-larger-than=.
-Wno-larger-than Disable -Wlarger-than= warning. Equivalent to -Wlarger-than=<SIZE_MAX> or larger. Same as -Wlarger-than=.
-Wno-stack-usage Disable -Wstack-usage= warning. Equivalent to -Wstack-usage=<SIZE_MAX> or larger. Same as -Wstack-usage=.
-Wno-vla-larger-than Disable Wvla-larger-than= warning. Equivalent to Wvla-larger-than=<SIZE_MAX> or larger. Same as -Wvla-larger-than=.
-Wnoexcept Warn when a noexcept expression evaluates to false even though the expression can't actually throw.
-Wnoexcept-type Warn if C++17 noexcept function type will change the mangled name of a symbol.
-Wnon-template-friend Warn when non-templatized friend functions are declared within a template.
-Wnon-virtual-dtor Warn about non-virtual destructors.
-Wnonnull Warn about NULL being passed to argument slots marked as requiring non-NULL.
-Wnonnull-compare Warn if comparing pointer parameter with nonnull attribute with NULL.
-Wnormalized Same as -Wnormalized=nfc (or, in negated form, -Wnormalized=none).
-Wnormalized=[none|id|nfc|nfkc] Warn about non-normalized Unicode strings.
-Wnull-dereference Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior.
-Wodr Warn about some C++ One Definition Rule violations during link time optimization.
-Wold-style-cast Warn if a C-style cast is used in a program.
-Wold-style-declaration Warn for obsolescent usage in a declaration.
-Wold-style-definition Warn if an old-style parameter definition is used.
-Wopenmp-simd Warn if a simd directive is overridden by the vectorizer cost model.
-Woverflow Warn about overflow in arithmetic expressions.
-Woverlength-strings Warn if a string is longer than the maximum portable length specified by the standard.
-Woverloaded-virtual Warn about overloaded virtual function names.
-Woverride-init Warn about overriding initializers without side effects.
-Woverride-init-side-effects Warn about overriding initializers with side effects.
-Woverwrite-recursive Warn that -fno-automatic may break recursion.
-Wpacked Warn when the packed attribute has no effect on struct layout.
-Wpacked-bitfield-compat Warn about packed bit-fields whose offset changed in GCC 4.4.
-Wpacked-not-aligned Warn when fields in a struct with the packed attribute are misaligned.
-Wpadded Warn when padding is required to align structure members.
-Wparentheses Warn about possibly missing parentheses.
-Wpedantic Issue warnings needed for strict compliance to the standard.
-Wpessimizing-move Warn about calling std::move on a local object in a return statement preventing copy elision.
-Wplacement-new Warn for placement new expressions with undefined behavior. Same as -Wplacement-new=.
-Wplacement-new=<0,2> Warn for placement new expressions with undefined behavior.
-Wpmf-conversions Warn when converting the type of pointers to member functions.
-Wpointer-arith Warn about function pointer arithmetic.
-Wpointer-compare Warn when a pointer is compared with a zero character constant.
-Wpointer-sign Warn when a pointer differs in signedness in an assignment.
-Wpointer-to-int-cast Warn when a pointer is cast to an integer of a different size.
-Wpragmas Warn about misuses of pragmas.
-Wprio-ctor-dtor Warn if constructor or destructors with priorities from 0 to 100 are used.
-Wproperty-assign-default Warn if a property for an Objective-C object has no assign semantics specified.
-Wprotocol Warn if inherited methods are unimplemented.
-Wpsabi This option lacks documentation.
-Wreal-q-constant Warn about real-literal-constants with 'q' exponent-letter.
-Wrealloc-lhs Warn when a left-hand-side array variable is reallocated.
-Wrealloc-lhs-all Warn when a left-hand-side variable is reallocated.
-Wredundant-decls Warn about multiple declarations of the same object.
-Wredundant-move Warn about redundant calls to std::move.
-Wredundant-tags Warn when a class or enumerated type is referenced using a redundant class-key.
-Wregister Warn about uses of register storage specifier.
-Wreorder Warn when the compiler reorders code.
-Wrestrict Warn when an argument passed to a restrict-qualified parameter aliases with another argument.
-Wreturn-local-addr Warn about returning a pointer/reference to a local or temporary variable.
-Wreturn-type Warn whenever a function's return type defaults to "int" (C), or about inconsistent return types (C++).
-Wscalar-storage-order Warn on suspicious constructs involving reverse scalar storage order.
-Wselector Warn if a selector has multiple methods.
-Wsequence-point Warn about possible violations of sequence point rules.
-Wshadow Warn when one variable shadows another. Same as -Wshadow=global.
-Wshadow-compatible-local Same as -Wshadow=compatible-local.
-Wshadow-ivar Warn if a local declaration hides an instance variable.
-Wshadow-local Same as -Wshadow=local.
-Wshadow=compatible-local Warn when one local variable shadows another local variable or parameter of compatible type.
-Wshadow=global Warn when one variable shadows another (globally). Same as -Wshadow.
-Wshadow=local Warn when one local variable shadows another local variable or parameter.
-Wshift-count-negative Warn if shift count is negative.
-Wshift-count-overflow Warn if shift count >= width of type.
-Wshift-negative-value Warn if left shifting a negative value.
-Wshift-overflow Warn if left shift of a signed value overflows. Same as -Wshift-overflow=.
-Wshift-overflow=<0,2> Warn if left shift of a signed value overflows.
-Wsign-compare Warn about signed-unsigned comparisons.
-Wsign-conversion Warn for implicit type conversions between signed and unsigned integers.
-Wsign-promo Warn when overload promotes from unsigned to signed.
-Wsized-deallocation Warn about missing sized deallocation functions.
-Wsizeof-array-argument Warn when sizeof is applied on a parameter declared as an array.
-Wsizeof-pointer-div Warn about suspicious divisions of two sizeof expressions that don't work correctly with pointers.
-Wsizeof-pointer-memaccess Warn about suspicious length parameters to certain string functions if the argument uses sizeof.
-Wstack-protector Warn when not issuing stack smashing protection for some reason.
-Wstack-usage=<byte-size> Warn if stack usage might exceed <byte-size>.
-Wstrict-aliasing Warn about code which might break strict aliasing rules.
-Wstrict-aliasing=<0,3> Warn about code which might break strict aliasing rules.
-Wstrict-null-sentinel Warn about uncasted NULL used as sentinel.
-Wstrict-overflow Warn about optimizations that assume that signed overflow is undefined.
-Wstrict-overflow=<0,5> Warn about optimizations that assume that signed overflow is undefined.
-Wstrict-prototypes Warn about unprototyped function declarations.
-Wstrict-selector-match Warn if type signatures of candidate methods do not match exactly.
-Wstring-compare Warn about calls to strcmp and strncmp used in equality expressions that are necessarily true or false due to the length of one and size of the other argument.
-Wstringop-overflow Warn about buffer overflow in string manipulation functions like memcpy and strcpy. Same as -Wstringop-overflow=.
-Wstringop-overflow=<0,4> Under the control of Object Size type, warn about buffer overflow in string manipulation functions like memcpy and strcpy.
-Wstringop-truncation Warn about truncation in string manipulation functions like strncat and strncpy.
-Wsubobject-linkage Warn if a class type has a base or a field whose type uses the anonymous namespace or depends on a type with no linkage.
-Wsuggest-attribute=cold Warn about functions which might be candidates for __attribute__((cold)).
-Wsuggest-attribute=const Warn about functions which might be candidates for __attribute__((const)).
-Wsuggest-attribute=format Warn about functions which might be candidates for format attributes.
-Wsuggest-attribute=malloc Warn about functions which might be candidates for __attribute__((malloc)).
-Wsuggest-attribute=noreturn Warn about functions which might be candidates for __attribute__((noreturn)).
-Wsuggest-attribute=pure Warn about functions which might be candidates for __attribute__((pure)).
-Wsuggest-final-methods Warn about C++ virtual methods where adding final keyword would improve code quality.
-Wsuggest-final-types Warn about C++ polymorphic types where adding final keyword would improve code quality.
-Wsuggest-override Suggest that the override keyword be used when the declaration of a virtual function overrides another.
-Wsurprising Warn about "suspicious" constructs.
-Wswitch Warn about enumerated switches, with no default, missing a case.
-Wswitch-bool Warn about switches with boolean controlling expression.
-Wswitch-default Warn about enumerated switches missing a "default:" statement.
-Wswitch-enum Warn about all enumerated switches missing a specific case.
-Wswitch-outside-range Warn about switch values that are outside of the switch's type range.
-Wswitch-unreachable Warn about statements between switch's controlling expression and the first case.
-Wsync-nand Warn when __sync_fetch_and_nand and __sync_nand_and_fetch built-in functions are used.
-Wsynth Deprecated. This switch has no effect.
-Wsystem-headers Do not suppress warnings from system headers.
-Wtabs Permit nonconforming uses of the tab character.
-Wtarget-lifetime Warn if the pointer in a pointer assignment might outlive its target.
-Wtautological-compare Warn if a comparison always evaluates to true or false.
-Wtemplates Warn on primary template declaration.
-Wterminate Warn if a throw expression will always result in a call to terminate().
-Wtraditional Warn about features not present in traditional C.
-Wtraditional-conversion Warn of prototypes causing type conversions different from what would happen in the absence of prototype.
-Wtrampolines Warn whenever a trampoline is generated.
-Wtrigraphs Warn if trigraphs are encountered that might affect the meaning of the program.
-Wtype-limits Warn if a comparison is always true or always false due to the limited range of the data type.
-Wundeclared-selector Warn about @selector()s without previously declared methods.
-Wundef Warn if an undefined macro is used in an #if directive.
-Wundefined-do-loop Warn about an invalid DO loop.
-Wunderflow Warn about underflow of numerical constant expressions.
-Wuninitialized Warn about uninitialized automatic variables.
-Wunknown-pragmas Warn about unrecognized pragmas.
-Wunreachable-code Does nothing. Preserved for backward compatibility.
-Wunsafe-loop-optimizations Does nothing. Preserved for backward compatibility.
-Wunsuffixed-float-constants Warn about unsuffixed float constants.
-Wunused Enable all -Wunused- warnings.
-Wunused-but-set-parameter Warn when a function parameter is only set, otherwise unused.
-Wunused-but-set-variable Warn when a variable is only set, otherwise unused.
-Wunused-const-variable Warn when a const variable is unused. Same as -Wunused-const-variable=.
-Wunused-const-variable=<0,2> Warn when a const variable is unused.
-Wunused-dummy-argument Warn about unused dummy arguments.
-Wunused-function Warn when a function is unused.
-Wunused-label Warn when a label is unused.
-Wunused-local-typedefs Warn when typedefs locally defined in a function are not used.
-Wunused-macros Warn about macros defined in the main file that are not used.
-Wunused-parameter Warn when a function parameter is unused.
-Wunused-result Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value.
-Wunused-value Warn when an expression value is unused.
-Wunused-variable Warn when a variable is unused.
-Wuse-without-only Warn about USE statements that have no ONLY qualifier.
-Wuseless-cast Warn about useless casts.
-Wvarargs Warn about questionable usage of the macros used to retrieve variable arguments.
-Wvariadic-macros Warn about using variadic macros.
-Wvector-operation-performance Warn when a vector operation is compiled outside the SIMD.
-Wvirtual-inheritance Warn on direct virtual inheritance.
-Wvirtual-move-assign Warn if a virtual base has a non-trivial move assignment operator.
-Wvla Warn if a variable length array is used.
-Wvla-larger-than=<number> Warn on unbounded uses of variable-length arrays, and on bounded uses of variable-length arrays whose bound can be larger than <number> bytes. <number> bytes.
-Wvolatile Warn about deprecated uses of volatile qualifier.
-Wvolatile-register-var Warn when a register variable is declared volatile.
-Wwrite-strings In C++, nonzero means warn about deprecated conversion from string literals to 'char *'. In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard.
-Wzero-as-null-pointer-constant Warn when a literal '0' is used as null pointer.
-Wzero-length-bounds Warn about accesses to interior zero-length array members.
-Wzerotrip Warn about zero-trip DO loops.
-frequire-return-statement Functions which return values must end with return statements.

See also

The cl options for warnings (/W…)
GCC options

Index