I read this question that explains how anonymous variables are invalid in C++.
But the following program compiles without any warning or errors on GCC 7.2 (even with -Wall
) - demo:
int main() {
int (*); // anonymous variable?
}
Here, this is apparently also an integer type anonymous variable. So, why GCC does not show any errors or warnings? Is this a GCC bug?
GCC 4.3+ now has -Q --help=warnings , and you can even specify --help=warnings,C to just print out the C related warnings.
You can use the -Werror compiler flag to turn all or some warnings into errors. Show activity on this post. You can use -fdiagnostics-show-option to see the -W option that applies to a particular warning.
Warn about uninitialized variables that are initialized with themselves. Note this option can only be used with the -Wuninitialized option. This warning is enabled by -Wall in C++. This option controls warnings when a declaration does not specify a type.
gcc -Wall enables all compiler's warning messages. This option should always be used, in order to generate better code.
There have been bugs recorded with gcc and how it detects variables for example I was using it to compile a simple program and it gave an error saying variable may be uninitialized when it have been. It is just a bug in the compiler. For example see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55985
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With