Why “not all control paths return a value” is warning and not an error?

Failing to return a value from a function that has a non-void return type results in undefined behaviour, but is not a semantic error. The reason for this, as far as I can determine, is largely historical. C originally didn’t have void and implicit int meant that most functions returned an int unless explicitly declared … Read more

How to set ‘-Xuse-experimental=kotlin.experimental’ in IntelliJ

Are you using Maven or Gradle for your project? I had the same issue with Gradle, but I was able to remove the warnings by putting the -Xuse-experimental=kotlin.Experimental in my build.gradle file, inside a tasks.withType. For KtorExperimentalLocationsAPI you could try: tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions.freeCompilerArgs += [“-Xuse-experimental=io.ktor.locations.KtorExperimentalLocationsAPI”] }

How can I get a warning when comparing unsigned integers of different sizes in C and C++?

There does not appear to be a warning option built in to gcc or clang that does what is requested. However, we can use clang-query instead. Below is a clang-query command that will report comparison of 32-bit and 64-bit integers, on the assumption that int is 32 bits and long is 64 bits. (More about … Read more

How can I disable compiler warnings in Eclipse on a file specific basis? [duplicate]

Ensure the files are under the gen folder, the typical home for all generated .java files. Then in the project properties, under Java Build Path, set Ignore optional compile problems for that folder to Yes. If your project structure requires your files be in a folder other than gen, add that folder to the Java … Read more

GCC does not honor ‘pragma GCC diagnostic’ to silence warnings [duplicate]

This appears to be a bug in gcc at least. The following code: #pragma GCC diagnostic ignored “-Wunknown-pragmas” #pragma GCC diagnostic ignored “-Wuninitialized” int fn(void) { #pragma xyzzy int x; return x; } int main (void) { return fn(); } has no problems ignoring the uninitialised x value but still complains about the pragma (without … Read more

How can I get a warning when comparing unsigned integers of different size in C and C++?

There does not appear to be a warning option built in to gcc or clang that does what is requested. However, we can use clang-query instead. Below is a clang-query command that will report comparison of 32-bit and 64-bit integers, on the assumption that int is 32 bits and long is 64 bits. (More about … Read more

Disable GCC “may be used uninitialized” on a particular variable

Try doing this: #pragma GCC diagnostic ignored “-Wuninitialized” foo(b); /* no diagnostic for this one */ This pragma comes in three interesting and helpful flavors : warning, error, ignored. See 6.56.10 Diagnostic Pragmas for their usages. The link says, GCC allows the user to selectively enable or disable certain types of diagnostics, and change the … Read more