neulab/tldr huggingface dataset:
struct B: public A { void f(int); };
the "A" class version of "f" is hidden in "B", and code like:
B* b; b->f();
fails to compile.
-Wno-pmf-conversions (C++ and Objective-C++ only) Disable the diagnostic for converting a bound pointer to member function to a plain pointer.
-Wsign-promo (C++ and Objective-C++ only) Warn when overload resolution chooses a promotion from unsigned or enumerated type to a signed type, over a conversion to an unsigned type of the same size.  Previous versions of G++ tried to preserve unsignedness, but the standard mandates the current behavior.
-Wtemplates (C++ and Objective-C++ only) Warn when a primary template declaration is encountered.  Some coding rules disallow templates, and this may be used to enforce that rule. The warning is inactive inside a system header file, such as the STL, so one can still use the STL.  One may also instantiate or specialize templates.
-Wno-mismatched-new-delete (C++ and Objective-C++ only) Warn for mismatches between calls to "operator new" or "operator delete" and the corresponding call to the allocation or deallocation function.  This includes invocations of C++ "operator delete" with pointers returned from either mismatched forms of "operator new", or from other functions that allocate objects for which the "operator delete" isn't a suitable deallocator, as well as calls to other deallocation functions with pointers returned from "operator new" for which the deallocation function isn't suitable.
For example, the "delete" expression in the function below is diagnosed because it doesn't match the array form of the "new" expression the pointer argument was returned from.  Similarly, the call to "free" is also diagnosed.
void f () { int *a = new int[n]; delete a;   // warning: mismatch in array forms of expressions
char *p = new char[n]; free (p);   // warning: mismatch between new and free }
The related option -Wmismatched-dealloc diagnoses mismatches involving allocation and deallocation functions other than "operator new" and "operator delete".
-Wmismatched-new-delete is enabled by default.
-Wmismatched-tags (C++ and Objective-C++ only) Warn for declarations of structs, classes, and class templates and their specializations with a class-key that does not match either the definition or the first declaration if no definition is provided.
For example, the declaration of "struct Object" in the argument list of "draw" triggers the warning.  To avoid it, either remove the redundant class-key "struct" or replace it with "class" to match its definition.
class Object { public: virtual ~Object () = 0; }; void draw (struct Object*);
It is not wrong to declare a class with the class-key "struct" as the example above shows.  The -Wmismatched-tags option is intended to help achieve a consistent style of class declarations.  In code that is intended to be portable to Windows-based compilers the warning helps prevent unresolved references due to the difference in the mangling of symbols declared with different class-keys.  The option can be used either on its own or in conjunction with -Wredundant-tags.
-Wmultiple-inheritance (C++ and Objective-C++ only) Warn when a class is defined with multiple direct base classes.  Some coding rules disallow multiple inheritance, and this may be used to enforce that rule.  The warning is inactive inside a system header file, such as the STL, so one can still use the STL.  One may also define classes that indirectly use multiple inheritance.
-Wvirtual-inheritance Warn when a class is defined with a virtual direct base class.  Some coding rules disallow multiple inheritance, and this may be used to enforce that rule.  The warning is inactive inside a system header file, such as the STL, so one can still use the STL.  One may also define classes that indirectly use virtual inheritance.
-Wno-virtual-move-assign Suppress warnings about inheriting from a virtual base with a non- trivial C++11 move assignment operator.  This is dangerous because if the virtual base is reachable along more than one path, it is moved multiple times, which can mean both objects end up in the moved-from state.  If the move assignment operator is written to avoid moving from a moved-from object, this warning can be disabled.
-Wnamespaces Warn when a namespace definition is opened.  Some coding rules disallow namespaces, and this may be used to enforce that rule.  The warning is inactive inside a system header file, such as the STL, so one can still use the STL.  One may also use using directives and qualified names.
-Wno-terminate (C++ and Objective-C++ only) Disable the warning about a throw-expression that will immediately result in a call to "terminate".
-Wno-vexing-parse (C++ and Objective-C++ only) Warn about the most vexing parse syntactic ambiguity.  This warns about the cases when a declaration looks like a variable definition, but the C++ language requires it to be interpreted as a function declaration.  For instance:
void f(double a) { int i();        // extern int i (void); int n(int(a));  // extern int n (int); }
Another example:
struct S { S(int); }; void f(double a) { S x(int(a));   // extern struct S x (int); S y(int());    // extern struct S y (int (*) (void)); S z();         // extern struct S z (void); }
The warning will suggest options how to deal with such an ambiguity; e.g., it can suggest removing the parentheses or using braces instead.
This warning is enabled by default.
-Wno-class-conversion (C++ and Objective-C++ only) Do not warn when a conversion function converts an object to the same type, to a base class of that type, or to void; such a conversion function will never be called.
-Wvolatile (C++ and Objective-C++ only) Warn about deprecated uses of the "volatile" qualifier.  This includes postfix and prefix "++" and "--" expressions of "volatile"-qualified types, using simple assignments where the left operand is a "volatile"-qualified non-class type for their value, compound assignments where the left operand is a "volatile"-qualified non-class type, "volatile"-qualified function return type, "volatile"-qualified parameter type, and structured bindings of a "volatile"-qualified type.  This usage was deprecated in C++20.
-Wzero-as-null-pointer-constant (C++ and Objective-C++ only) Warn when a literal 0 is used as null pointer constant.  This can be useful to facilitate the conversion to "nullptr" in C++11.
-Waligned-new Warn about a new-expression of a type that requires greater alignment than the "alignof(std::max_align_t)" but uses an allocation function without an explicit alignment parameter. This option is enabled by -Wall.
Normally this only warns about global allocation functions, but -Waligned-new=all also warns about class member allocation functions.
-Wno-placement-new -Wplacement-new=n Warn about placement new expressions with undefined behavior, such as constructing an object in a buffer that is smaller than the type of the object.  For example, the placement new expression below is diagnosed because it attempts to construct an array of 64 integers in a buffer only 64 bytes large.
char buf [64]; new (buf) int[64];
-Wplacement-new=1 This is the default warning level of -Wplacement-new.  At this level the warning is not issued for some strictly undefined constructs that GCC allows as extensions for compatibility with legacy code.  For example, the following "new" expression is not diagnosed at this level even though it has undefined behavior according to the C++ standard because it writes past the end of the one-element array.
struct S { int n, a[1]; }; S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); new (s->a)int [32]();
-Wplacement-new=2 At this level, in addition to diagnosing all the same constructs as at level 1, a diagnostic is also issued for placement new expressions that construct an object in the last member of structure whose type is an array of a single element and whose size is less than the size of the object being constructed. While the previous example would be diagnosed, the following construct makes use of the flexible member array extension to avoid the warning at level 2.
struct S { int n, a[]; }; S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); new (s->a)int [32]();
-Wcatch-value -Wcatch-value=n (C++ and Objective-C++ only) Warn about catch handlers that do not catch via reference.  With -Wcatch-value=1 (or -Wcatch-value for short) warn about polymorphic class types that are caught by value.  With -Wcatch-value=2 warn about all class types that are caught by value. With -Wcatch-value=3 warn about all types that are not caught by reference. -Wcatch-value is enabled by -Wall.
-Wconditionally-supported (C++ and Objective-C++ only) Warn for conditionally-supported (C++11 [intro.defs]) constructs.
-Wno-delete-incomplete (C++ and Objective-C++ only) Do not warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime.  This warning is enabled by default.
-Wextra-semi (C++, Objective-C++ only) Warn about redundant semicolons after in-class function definitions.
-Wno-inaccessible-base (C++, Objective-C++ only) This option controls warnings when a base class is inaccessible in a class derived from it due to ambiguity.  The warning is enabled by default.  Note that the warning for ambiguous virtual bases is enabled by the -Wextra option.
struct A { int a; };
struct B : A { };
struct C : B, A { };
-Wno-inherited-variadic-ctor Suppress warnings about use of C++11 inheriting constructors when the base class inherited from has a C variadic constructor; the warning is on by default because the ellipsis is not inherited.
-Wno-invalid-offsetof (C++ and Objective-C++ only) Suppress warnings from applying the "offsetof" macro to a non-POD type.  According to the 2014 ISO C++ standard, applying "offsetof" to a non-standard-layout type is undefined.  In existing C++ implementations, however, "offsetof" typically gives meaningful results.  This flag is for users who are aware that they are writing nonportable code and who have deliberately chosen to ignore the warning about it.
The restrictions on "offsetof" may be relaxed in a future version of the C++ standard.
-Wsized-deallocation (C++ and Objective-C++ only) Warn about a definition of an unsized deallocation function
void operator delete (void *) noexcept; void operator delete[] (void *) noexcept;
without a definition of the corresponding sized deallocation function
or vice versa.  Enabled by -Wextra along with -fsized-deallocation.
-Wsuggest-final-types Warn about types with virtual methods where code quality would be improved if the type were declared with the C++11 "final" specifier, or, if possible, declared in an anonymous namespace. This allows GCC to more aggressively devirtualize the polymorphic calls. This warning is more effective with link-time optimization, where the information about the class hierarchy graph is more complete.
-Wsuggest-final-methods Warn about virtual methods where code quality would be improved if the method were declared with the C++11 "final" specifier, or, if possible, its type were declared in an anonymous namespace or with the "final" specifier.  This warning is more effective with link-time optimization, where the information about the class hierarchy graph is more complete. It is recommended to first consider suggestions of -Wsuggest-final-types and then rebuild with new annotations.
-Wsuggest-override Warn about overriding virtual functions that are not marked with the "override" keyword.
-Wuseless-cast (C++ and Objective-C++ only) Warn when an expression is casted to its own type.
-Wno-conversion-null (C++ and Objective-C++ only) Do not warn for conversions between "NULL" and non-pointer types. -Wconversion-null is enabled by default.
Options Controlling Objective-C and Objective-C++ Dialects (NOTE: This manual does not describe the Objective-C and Objective-C++ languages themselves.
This section describes the command-line options that are only meaningful for Objective-C and Objective-C++ programs.  You can also use most of the language-independent GNU compiler options.  For example, you might compile a file some_class.m like this:
gcc -g -fgnu-runtime -O -c some_class.m
In this example, -fgnu-runtime is an option meant only for Objective-C and Objective-C++ programs; you can use the other options with any language supported by GCC.
Note that since Objective-C is an extension of the C language, Objective- C compilations may also use options specific to the C front-end (e.g., -Wtraditional).  Similarly, Objective-C++ compilations may use C++-specific options (e.g., -Wabi).
Here is a list of options that are only for compiling Objective-C and Objective-C++ programs:
-fconstant-string-class=class-name Use class-name as the name of the class to instantiate for each literal string specified with the syntax "@"..."".  The default class name is "NXConstantString" if the GNU runtime is being used, and "NSConstantString" if the NeXT runtime is being used (see below). The -fconstant-cfstrings option, if also present, overrides the -fconstant-string-class setting and cause "@"..."" literals to be laid out as constant CoreFoundation strings.
-fgnu-runtime Generate object code compatible with the standard GNU Objective-C runtime.  This is the default for most types of systems.
-fnext-runtime Generate output compatible with the NeXT runtime.  This is the default for NeXT-based systems, including Darwin and Mac OS X.  The macro "__NEXT_RUNTIME__" is predefined if (and only if) this option is used.
-fno-nil-receivers Assume that all Objective-C message dispatches ("[receiver message:arg]") in this translation unit ensure that the receiver is not "nil".  This allows for more efficient entry points in the runtime to be used.  This option is only available in conjunction with the NeXT runtime and ABI version 0 or 1.
-fobjc-abi-version=n Use version n of the Objective-C ABI for the selected runtime.  This option is currently supported only for the NeXT runtime.  In that case, Version 0 is the traditional (32-bit) ABI without support for properties and other Objective-C 2.0 additions.  Version 1 is the traditional (32-bit) ABI with support for properties and other Objective-C 2.0 additions.  Version 2 is the modern (64-bit) ABI.  If nothing is specified, the default is Version 0 on 32-bit target machines, and Version 2 on 64-bit target machines.
-fobjc-call-cxx-cdtors For each Objective-C class, check if any of its instance variables is a C++ object with a non-trivial default constructor.  If so, synthesize a special "- (id) .cxx_construct" instance method which runs non-trivial default constructors on any such instance variables, in order, and then return "self".  Similarly, check if any instance variable is a C++ object with a non-trivial destructor, and if so, synthesize a special "- (void) .cxx_destruct" method which runs all such default destructors, in reverse order.
The "- (id) .cxx_construct" and "- (void) .cxx_destruct" methods thusly generated only operate on instance variables declared in the current Objective-C class, and not those inherited from superclasses. It is the responsibility of the Objective-C runtime to invoke all such methods in an object's inheritance hierarchy.  The "- (id) .cxx_construct" methods are invoked by the runtime immediately after a new object instance is allocated; the "- (void) .cxx_destruct" methods are invoked immediately before the runtime deallocates an object instance.
As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has support for invoking the "- (id) .cxx_construct" and "- (void) .cxx_destruct" methods.
-fobjc-direct-dispatch Allow fast jumps to the message dispatcher.  On Darwin this is accomplished via the comm page.
-fobjc-exceptions Enable syntactic support for structured exception handling in Objective-C, similar to what is offered by C++.  This option is required to use the Objective-C keywords @try, @throw, @catch, @finally and @synchronized.  This option is available with both the GNU runtime and the NeXT runtime (but not available in conjunction with the NeXT runtime on Mac OS X 10.2 and earlier).
-fobjc-gc Enable garbage collection (GC) in Objective-C and Objective-C++ programs.  This option is only available with the NeXT runtime; the GNU runtime has a different garbage collection implementation that does not require special compiler flags.
-fobjc-nilcheck For the NeXT runtime with version 2 of the ABI, check for a nil receiver in method invocations before doing the actual method call. This is the default and can be disabled using -fno-objc-nilcheck. Class methods and super calls are never checked for nil in this way no matter what this flag is set to.  Currently this flag does nothing when the GNU runtime, or an older version of the NeXT runtime ABI, is used.
-fobjc-std=objc1 Conform to the language syntax of Objective-C 1.0, the language recognized by GCC 4.0.  This only affects the Objective-C additions to the C/C++ language; it does not affect conformance to C/C++ standards, which is controlled by the separate C/C++ dialect option flags.  When this option is used with the Objective-C or Objective-C++ compiler, any Objective-C syntax that is not recognized by GCC 4.0 is rejected.  This is useful if you need to make sure that your Objective-C code can be compiled with older versions of GCC.
-freplace-objc-classes Emit a special marker instructing ld(1) not to statically link in the resulting object file, and allow dyld(1) to load it in at run time instead.  This is used in conjunction with the Fix-and-Continue debugging mode, where the object file in question may be recompiled and dynamically reloaded in the course of program execution, without the need to restart the program itself.  Currently, Fix-and-Continue functionality is only available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
-fzero-link When compiling for the NeXT runtime, the compiler ordinarily replaces calls to "objc_getClass("...")" (when the name of the class is known at compile time) with static class references that get initialized at load time, which improves run-time performance.  Specifying the -fzero-link flag suppresses this behavior and causes calls to "objc_getClass("...")"  to be retained.  This is useful in Zero-Link debugging mode, since it allows for individual class implementations to be modified during program execution.  The GNU runtime currently always retains calls to "objc_get_class("...")"  regardless of command-line options.
-fno-local-ivars By default instance variables in Objective-C can be accessed as if they were local variables from within the methods of the class they're declared in.  This can lead to shadowing between instance variables and other variables declared either locally inside a class method or globally with the same name.  Specifying the -fno-local-ivars flag disables this behavior thus avoiding variable shadowing issues.
-fivar-visibility=[public|protected|private|package] Set the default instance variable visibility to the specified option so that instance variables declared outside the scope of any access modifier directives default to the specified visibility.
-gen-decls Dump interface declarations for all classes seen in the source file to a file named sourcename.decl.
-Wassign-intercept (Objective-C and Objective-C++ only) Warn whenever an Objective-C assignment is being intercepted by the garbage collector.
-Wno-property-assign-default (Objective-C and Objective-C++ only) Do not warn if a property for an Objective-C object has no assign semantics specified.
-Wno-protocol (Objective-C and Objective-C++ only) If a class is declared to implement a protocol, a warning is issued for every method in the protocol that is not implemented by the class.  The default behavior is to issue a warning for every method not explicitly implemented in the class, even if a method implementation is inherited from the superclass.  If you use the -Wno-protocol option, then methods inherited from the superclass are considered to be implemented, and no warning is issued for them.
-Wobjc-root-class (Objective-C and Objective-C++ only) Warn if a class interface lacks a superclass. Most classes will inherit from "NSObject" (or "Object") for example.  When declaring classes intended to be root classes, the warning can be suppressed by marking their interfaces with "__attribute__((objc_root_class))".
-Wselector (Objective-C and Objective-C++ only) Warn if multiple methods of different types for the same selector are found during compilation.  The check is performed on the list of methods in the final stage of compilation.  Additionally, a check is performed for each selector appearing in a "@selector(...)" expression, and a corresponding method for that selector has been found during compilation.  Because these checks scan the method table only at the end of compilation, these warnings are not produced if the final stage of compilation is not reached, for example because an error is found during compilation, or because the -fsyntax-only option is being used.
-Wstrict-selector-match (Objective-C and Objective-C++ only) Warn if multiple methods with differing argument and/or return types are found for a given selector when attempting to send a message using this selector to a receiver of type "id" or "Class".  When this flag is off (which is the default behavior), the compiler omits such warnings if any differences found are confined to types that share the same size and alignment.
-Wundeclared-selector (Objective-C and Objective-C++ only) Warn if a "@selector(...)" expression referring to an undeclared selector is found.  A selector is considered undeclared if no method with that name has been declared before the "@selector(...)" expression, either explicitly in an @interface or @protocol declaration, or implicitly in an @implementation section.  This option always performs its checks as soon as a "@selector(...)" expression is found, while -Wselector only performs its checks in the final stage of compilation.  This also enforces the coding style convention that methods and selectors must be declared before being used.
-print-objc-runtime-info Generate C header describing the largest structure that is passed by value, if any.
Options to Control Diagnostic Messages Formatting Traditionally, diagnostic messages have been formatted irrespective of the output device's aspect (e.g. its width, ...).  You can use the options described below to control the formatting algorithm for diagnostic messages, e.g. how many characters per line, how often source location information should be reported.  Note that some language front ends may not honor these options.
-fmessage-length=n Try to format error messages so that they fit on lines of about n characters.  If n is zero, then no line-wrapping is done; each error message appears on a single line.  This is the default for all front ends.
Note - this option also affects the display of the #error and #warning pre-processor directives, and the deprecated function/type/variable attribute.  It does not however affect the pragma GCC warning and pragma GCC error pragmas.
-fdiagnostics-plain-output This option requests that diagnostic output look as plain as possible, which may be useful when running dejagnu or other utilities that need to parse diagnostics output and prefer that it remain more stable over time.  -fdiagnostics-plain-output is currently equivalent to the following options: -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-color=never -fdiagnostics-urls=never -fdiagnostics-path-format=separate-events In the future, if GCC changes the default appearance of its diagnostics, the corresponding option to disable the new behavior will be added to this list.
-fdiagnostics-show-location=once Only meaningful in line-wrapping mode.  Instructs the diagnostic messages reporter to emit source location information once; that is, in case the message is too long to fit on a single physical line and has to be wrapped, the source location won't be emitted (as prefix) again, over and over, in subsequent continuation lines.  This is the default behavior.
-fdiagnostics-show-location=every-line Only meaningful in line-wrapping mode.  Instructs the diagnostic messages reporter to emit the same source location information (as prefix) for physical lines that result from the process of breaking a message which is too long to fit on a single line.
-fdiagnostics-color[=WHEN] -fno-diagnostics-color Use color in diagnostics.  WHEN is never, always, or auto.  The default depends on how the compiler has been configured, it can be any of the above WHEN options or also never if GCC_COLORS environment variable isn't present in the environment, and auto otherwise.  auto makes GCC use color only when the standard error is a terminal, and when not executing in an emacs shell.  The forms -fdiagnostics-color and -fno-diagnostics-color are aliases for -fdiagnostics-color=always and -fdiagnostics-color=never, respectively.
The colors are defined by the environment variable GCC_COLORS.  Its value is a colon-separated list of capabilities and Select Graphic Rendition (SGR) substrings. SGR commands are interpreted by the terminal or terminal emulator.  (See the section in the documentation of your text terminal for permitted values and their meanings as character attributes.)  These substring values are integers in decimal representation and can be concatenated with semicolons. Common values to concatenate include 1 for bold, 4 for underline, 5 for blink, 7 for inverse, 39 for default foreground color, 30 to 37 for foreground colors, 90 to 97 for 16-color mode foreground colors, 38;5;0 to 38;5;255 for 88-color and 256-color modes foreground colors, 49 for default background color, 40 to 47 for background colors, 100 to 107 for 16-color mode background colors, and 48;5;0 to 48;5;255 for 88-color and 256-color modes background colors.
The default GCC_COLORS is
error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ type-diff=01;32
where 01;31 is bold red, 01;35 is bold magenta, 01;36 is bold cyan, 32 is green, 34 is blue, 01 is bold, and 31 is red.  Setting GCC_COLORS to the empty string disables colors.  Supported capabilities are as follows.
"error=" SGR substring for error: markers.
"warning=" SGR substring for warning: markers.
"note=" SGR substring for note: markers.
"path=" SGR substring for colorizing paths of control-flow events as printed via -fdiagnostics-path-format=, such as the identifiers of individual events and lines indicating interprocedural calls and returns.
"range1=" SGR substring for first additional range.
"range2=" SGR substring for second additional range.
"locus=" SGR substring for location information, file:line or file:line:column etc.
"quote=" SGR substring for information printed within quotes.
"fixit-insert=" SGR substring for fix-it hints suggesting text to be inserted or replaced.
"fixit-delete=" SGR substring for fix-it hints suggesting text to be deleted.
"diff-filename=" SGR substring for filename headers within generated patches.
"diff-hunk=" SGR substring for the starts of hunks within generated patches.
"diff-delete=" SGR substring for deleted lines within generated patches.
"diff-insert=" SGR substring for inserted lines within generated patches.
"type-diff=" SGR substring for highlighting mismatching types within template arguments in the C++ frontend.
-fdiagnostics-urls[=WHEN] Use escape sequences to embed URLs in diagnostics.  For example, when -fdiagnostics-show-option emits text showing the command-line option controlling a diagnostic, embed a URL for documentation of that option.
WHEN is never, always, or auto.  auto makes GCC use URL escape sequences only when the standard error is a terminal, and when not executing in an emacs shell or any graphical terminal which is known to be incompatible with this feature, see below.
The default depends on how the compiler has been configured.  It can be any of the above WHEN options.
GCC can also be configured (via the --with-diagnostics-urls=auto-if-env configure-time option) so that the default is affected by environment variables.  Under such a configuration, GCC defaults to using auto if either GCC_URLS or TERM_URLS environment variables are present and non-empty in the environment of the compiler, or never if neither are.
However, even with -fdiagnostics-urls=always the behavior is dependent on those environment variables: If GCC_URLS is set to empty or no, do not embed URLs in diagnostics.  If set to st, URLs use ST escape sequences.  If set to bel, the default, URLs use BEL escape sequences.  Any other non-empty value enables the feature.  If GCC_URLS is not set, use TERM_URLS as a fallback.  Note: ST is an ANSI escape sequence, string terminator ESC \, BEL is an ASCII character, CTRL-G that usually sounds like a beep.
At this time GCC tries to detect also a few terminals that are known to not implement the URL feature, and have bugs or at least had bugs in some versions that are still in use, where the URL escapes are likely to misbehave, i.e. print garbage on the screen.  That list is currently xfce4-terminal, certain known to be buggy gnome-terminal versions, the linux console, and mingw.  This check can be skipped with the -fdiagnostics-urls=always.
-fno-diagnostics-show-option By default, each diagnostic emitted includes text indicating the command-line option that directly controls the diagnostic (if such an option is known to the diagnostic machinery).  Specifying the -fno-diagnostics-show-option flag suppresses that behavior.
-fno-diagnostics-show-caret By default, each diagnostic emitted includes the original source line and a caret ^ indicating the column.  This option suppresses this information.  The source line is truncated to n characters, if the -fmessage-length=n option is given.  When the output is done to the terminal, the width is limited to the width given by the COLUMNS environment variable or, if not set, to the terminal width.
-fno-diagnostics-show-labels By default, when printing source code (via -fdiagnostics-show-caret), diagnostics can label ranges of source code with pertinent information, such as the types of expressions:
printf ("foo %s bar", long_i + long_j); ~^       ~~~~~~~~~~~~~~~ |              | char *         long int
This option suppresses the printing of these labels (in the example above, the vertical bars and the "char *" and "long int" text).
-fno-diagnostics-show-cwe Diagnostic messages can optionally have an associated @url{https://cwe.mitre.org/index.html, CWE} identifier.  GCC itself only provides such metadata for some of the -fanalyzer diagnostics. GCC plugins may also provide diagnostics with such metadata.  By default, if this information is present, it will be printed with the diagnostic.  This option suppresses the printing of this metadata.
-fno-diagnostics-show-line-numbers By default, when printing source code (via -fdiagnostics-show-caret), a left margin is printed, showing line numbers.  This option suppresses this left margin.
-fdiagnostics-minimum-margin-width=width This option controls the minimum width of the left margin printed by -fdiagnostics-show-line-numbers.  It defaults to 6.
-fdiagnostics-parseable-fixits Emit fix-it hints in a machine-parseable format, suitable for consumption by IDEs.  For each fix-it, a line will be printed after the relevant diagnostic, starting with the string "fix-it:".  For example:
fix-it:"test.c":{45:3-45:21}:"gtk_widget_show_all"
The location is expressed as a half-open range, expressed as a count of bytes, starting at byte 1 for the initial column.  In the above example, bytes 3 through 20 of line 45 of "test.c" are to be replaced with the given string:
00000000011111111112222222222 12345678901234567890123456789 gtk_widget_showall (dlg); ^^^^^^^^^^^^^^^^^^ gtk_widget_show_all
The filename and replacement string escape backslash as "\\", tab as "\t", newline as "\n", double quotes as "\"", non-printable characters as octal (e.g. vertical tab as "\013").
An empty replacement string indicates that the given range is to be removed.  An empty range (e.g. "45:3-45:3") indicates that the string is to be inserted at the given position.
-fdiagnostics-generate-patch Print fix-it hints to stderr in unified diff format, after any diagnostics are printed.  For example:
--- test.c +++ test.c @ -42,5 +42,5 @
void show_cb(GtkDialog *dlg) { -  gtk_widget_showall(dlg); +  gtk_widget_show_all(dlg); }
The diff may or may not be colorized, following the same rules as for diagnostics (see -fdiagnostics-color).
-fdiagnostics-show-template-tree In the C++ frontend, when printing diagnostics showing mismatching template types, such as:
could not convert 'std::map<int, std::vector<double> >()' from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
the -fdiagnostics-show-template-tree flag enables printing a tree- like structure showing the common and differing parts of the types, such as:
map< [...], vector< [double != float]>>
The parts that differ are highlighted with color ("double" and "float" in this case).
-fno-elide-type By default when the C++ frontend prints diagnostics showing mismatching template types, common parts of the types are printed as "[...]" to simplify the error message.  For example:
Specifying the -fno-elide-type flag suppresses that behavior.  This flag also affects the output of the -fdiagnostics-show-template-tree flag.
-fdiagnostics-path-format=KIND Specify how to print paths of control-flow events for diagnostics that have such a path associated with them.
KIND is none, separate-events, or inline-events, the default.
none means to not print diagnostic paths.
separate-events means to print a separate "note" diagnostic for each event within the diagnostic.  For example:
test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL test.c:27:3: note: (2) when 'i < count' test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
inline-events means to print the events "inline" within the source code.  This view attempts to consolidate the events into runs of sufficiently-close events, printing them as labelled ranges within the source.
For example, the same events as above might be printed as:
'test': events 1-3 | |   25 |   list = PyList_New(0); |      |          ^~~~~~~~~~~~~ |      |          | |      |          (1) when 'PyList_New' fails, returning NULL |   26 | |   27 |   for (i = 0; i < count; i++) { |      |   ~~~ |      |   | |      |   (2) when 'i < count' |   28 |     item = PyLong_FromLong(random()); |   29 |     PyList_Append(list, item); |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~ |      |     | |      |     (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 |
Interprocedural control flow is shown by grouping the events by stack frame, and using indentation to show how stack frames are nested, pushed, and popped.
'test': events 1-2 | |  133 | { |      | ^ |      | | |      | (1) entering 'test' |  134 |   boxed_int *obj = make_boxed_int (i); |      |                    ~~~~~~~~~~~~~~~~~~ |      |                    | |      |                    (2) calling 'make_boxed_int' | +--> 'make_boxed_int': events 3-4 | |  120 | { |      | ^ |      | | |      | (3) entering 'make_boxed_int' |  121 |   boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); |      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |      |                                    | |      |                                    (4) calling 'wrapped_malloc' | +--> 'wrapped_malloc': events 5-6 | |    7 | { |      | ^ |      | | |      | (5) entering 'wrapped_malloc' |    8 |   return malloc (size); |      |          ~~~~~~~~~~~~~ |      |          | |      |          (6) calling 'malloc' | <-------------+ | 'test': event 7 | |  138 |   free_boxed_int (obj); |      |   ^~~~~~~~~~~~~~~~~~~~ |      |   | |      |   (7) calling 'free_boxed_int' | (etc)
-fdiagnostics-show-path-depths This option provides additional information when printing control- flow paths associated with a diagnostic.
If this is option is provided then the stack depth will be printed for each run of events within -fdiagnostics-path-format=separate-events.
This is intended for use by GCC developers and plugin developers when debugging diagnostics that report interprocedural control flow.
-fno-show-column Do not print column numbers in diagnostics.  This may be necessary if diagnostics are being scanned by a program that does not understand the column numbers, such as dejagnu.
-fdiagnostics-column-unit=UNIT Select the units for the column number.  This affects traditional diagnostics (in the absence of -fno-show-column), as well as JSON format diagnostics if requested.
The default UNIT, display, considers the number of display columns occupied by each character.  This may be larger than the number of bytes required to encode the character, in the case of tab characters, or it may be smaller, in the case of multibyte characters.  For example, the character "GREEK SMALL LETTER PI (U+03C0)" occupies one display column, and its UTF-8 encoding requires two bytes; the character "SLIGHTLY SMILING FACE (U+1F642)" occupies two display columns, and its UTF-8 encoding requires four bytes.
Setting UNIT to byte changes the column number to the raw byte count in all cases, as was traditionally output by GCC prior to version 11.1.0.
-fdiagnostics-column-origin=ORIGIN Select the origin for column numbers, i.e. the column number assigned to the first column.  The default value of 1 corresponds to traditional GCC behavior and to the GNU style guide.  Some utilities may perform better with an origin of 0; any non-negative value may be specified.
-fdiagnostics-format=FORMAT Select a different format for printing diagnostics.  FORMAT is text or json.  The default is text.
The json format consists of a top-level JSON array containing JSON objects representing the diagnostics.
The JSON is emitted as one line, without formatting; the examples below have been formatted for clarity.
Diagnostics can have child diagnostics.  For example, this error and note:
misleading-indentation.c:15:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation] 15 |   if (flag) |   ^~ misleading-indentation.c:17:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' 17 |     y = 2; |     ^
might be printed in JSON form (after formatting) like this:
[ { "kind": "warning", "locations": [ { "caret": { "display-column": 3, "byte-column": 3, "column": 3, "file": "misleading-indentation.c", "line": 15 }, "finish": { "display-column": 4, "byte-column": 4, "column": 4, "file": "misleading-indentation.c", "line": 15 } } ], "message": "this \u2018if\u2019 clause does not guard...", "option": "-Wmisleading-indentation", "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", "children": [ { "kind": "note", "locations": [ { "caret": { "display-column": 5, "byte-column": 5, "column": 5, "file": "misleading-indentation.c", "line": 17 } } ], "message": "...this statement, but the latter is ..." } ] "column-origin": 1, }, ... ]
where the "note" is a child of the "warning".
A diagnostic has a "kind".  If this is "warning", then there is an "option" key describing the command-line option controlling the warning.
A diagnostic can contain zero or more locations.  Each location has an optional "label" string and up to three positions within it: a "caret" position and optional "start" and "finish" positions.  A position is described by a "file" name, a "line" number, and three numbers indicating a column position:
*   "display-column" counts display columns, accounting for tabs and multibyte characters.
*   "byte-column" counts raw bytes.
*   "column" is equal to one of the previous two, as dictated by the -fdiagnostics-column-unit option.
All three columns are relative to the origin specified by -fdiagnostics-column-origin, which is typically equal to 1 but may be set, for instance, to 0 for compatibility with other utilities that number columns from 0.  The column origin is recorded in the JSON output in the "column-origin" tag.  In the remaining examples below, the extra column number outputs have been omitted for brevity.
For example, this error:
bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' {aka 'struct s'} and 'T' {aka 'struct t'}) 64 |   return callee_4a () + callee_4b (); |          ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ |          |              | |          |              T {aka struct t} |          S {aka struct s}
has three locations.  Its primary location is at the "+" token at column 23.  It has two secondary locations, describing the left and right-hand sides of the expression, which have labels.  It might be printed in JSON form as:
{ "children": [], "kind": "error", "locations": [ { "caret": { "column": 23, "file": "bad-binary-ops.c", "line": 64 } }, { "caret": { "column": 10, "file": "bad-binary-ops.c", "line": 64 }, "finish": { "column": 21, "file": "bad-binary-ops.c", "line": 64 }, "label": "S {aka struct s}" }, { "caret": { "column": 25, "file": "bad-binary-ops.c", "line": 64 }, "finish": { "column": 36, "file": "bad-binary-ops.c", "line": 64 }, "label": "T {aka struct t}" } ], "message": "invalid operands to binary + ..." }
If a diagnostic contains fix-it hints, it has a "fixits" array, consisting of half-open intervals, similar to the output of -fdiagnostics-parseable-fixits.  For example, this diagnostic with a replacement fix-it hint:
demo.c:8:15: error: 'struct s' has no member named 'colour'; did you mean 'color'? 8 |   return ptr->colour; |               ^~~~~~ |               color
might be printed in JSON form as:
{ "children": [], "fixits": [ { "next": { "column": 21, "file": "demo.c", "line": 8 }, "start": { "column": 15, "file": "demo.c", "line": 8 }, "string": "color" } ], "kind": "error", "locations": [ { "caret": { "column": 15, "file": "demo.c", "line": 8 }, "finish": { "column": 20, "file": "demo.c", "line": 8 } } ], "message": "\u2018struct s\u2019 has no member named ..." }
where the fix-it hint suggests replacing the text from "start" up to but not including "next" with "string"'s value.  Deletions are expressed via an empty value for "string", insertions by having "start" equal "next".
If the diagnostic has a path of control-flow events associated with it, it has a "path" array of objects representing the events.  Each event object has a "description" string, a "location" object, along with a "function" string and a "depth" number for representing interprocedural paths.  The "function" represents the current function at that event, and the "depth" represents the stack depth relative to some baseline: the higher, the more frames are within the stack.
For example, the intraprocedural example shown for -fdiagnostics-path-format= might have this JSON for its path:
"path": [ { "depth": 0, "description": "when 'PyList_New' fails, returning NULL", "function": "test", "location": { "column": 10, "file": "test.c", "line": 25 } }, { "depth": 0, "description": "when 'i < count'", "function": "test", "location": { "column": 3, "file": "test.c", "line": 27 } }, { "depth": 0, "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", "function": "test", "location": { "column": 5, "file": "test.c", "line": 29 } } ]
Options to Request or Suppress Warnings Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an error.
The following language-independent options do not enable specific warnings but control the kinds of diagnostics produced by GCC.
-fsyntax-only Check the code for syntax errors, but don't do anything beyond that.
-fmax-errors=n Limits the maximum number of error messages to n, at which point GCC bails out rather than attempting to continue processing the source code.  If n is 0 (the default), there is no limit on the number of error messages produced.  If -Wfatal-errors is also specified, then -Wfatal-errors takes precedence over this option.
-w  Inhibit all warning messages.
-Werror Make all warnings into errors.
-Werror= Make the specified warning into an error.  The specifier for a warning is appended; for example -Werror=switch turns the warnings controlled by -Wswitch into errors.  This switch takes a negative form, to be used to negate -Werror for specific warnings; for example -Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect.
The warning message for each controllable warning includes the option that controls the warning.  That option can then be used with -Werror= and -Wno-error= as described above.  (Printing of the option in the warning message can be disabled using the -fno-diagnostics-show-option flag.)
Note that specifying -Werror=foo automatically implies -Wfoo. However, -Wno-error=foo does not imply anything.
-Wfatal-errors This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages.
You can request many specific warnings with options beginning with -W, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning -Wno- to turn off warnings; for example, -Wno-implicit.  This manual lists only one of the two forms, whichever is not the default.  For further language-specific options also refer to C++ Dialect Options and Objective-C and Objective-C++ Dialect Options.  Additional warnings can be produced by enabling the static analyzer;
Some options, such as -Wall and -Wextra, turn on other options, such as -Wunused, which may turn on further options, such as -Wunused-value. The combined effect of positive and negative forms is that more specific options have priority over less specific ones, independently of their position in the command-line. For options of the same specificity, the last one takes effect. Options enabled or disabled via pragmas take effect as if they appeared at the end of the command-line.
When an unrecognized warning option is requested (e.g., -Wunknown-warning), GCC emits a diagnostic stating that the option is not recognized.  However, if the -Wno- form is used, the behavior is slightly different: no diagnostic is produced for -Wno-unknown-warning unless other diagnostics are being produced.  This allows the use of new -Wno- options with old compilers, but if something goes wrong, the compiler warns that an unrecognized option is present.
The effectiveness of some warnings depends on optimizations also being enabled. For example -Wsuggest-final-types is more effective with link- time optimization and -Wmaybe-uninitialized does not warn at all unless optimization is enabled.
-Wpedantic -pedantic Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++.  For ISO C, follows the version of the ISO C standard specified by any -std option used.
Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few require -ansi or a -std option specifying the required version of ISO C).  However, without this option, certain GNU extensions and traditional C and C++ features are supported as well.  With this option, they are rejected.
-Wpedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __.  This alternate format can also be used to disable warnings for non-ISO __intN types, i.e. __intN__.  Pedantic warnings are also disabled in the expression that follows "__extension__".  However, only system header files should use these escape routes; application programs should avoid them.
Some users try to use -Wpedantic to check programs for strict ISO C conformance.  They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all---only those for which ISO C requires a diagnostic, and some others for which diagnostics have been added.
A feature to report any failure to conform to ISO C might be useful in some instances, but would require considerable additional work and would be quite different from -Wpedantic.  We don't have plans to support such a feature in the near future.