Questions tagged [compiler-warnings]

Messages emitted by a compiler which indicate potential problems in code or configuration.

Compiler warnings typically flag patterns in code that could potentially cause problems, but for lack of context the compiler cannot declare absolutely that the code is flawed.

2652 questions
25
votes
2 answers

"control reaches end of non-void function" with fully handled case switch over an enum type

Why does this code trigger a "control reaches end of non-void function" even if all possible values of type_t are handled? What is the best way to take care of this warning? Adding a return -1 after the switch?(Code tested here) typedef enum { …
Antonio
  • 19,451
  • 13
  • 99
  • 197
25
votes
4 answers

Gradle - compileJava - remove compile Warnings

We use Gradle 2.1 and java plugin. During compileJava different warnings occur, for example: warning: [options] bootstrap class path not set in conjunction with -source 1.7 Note: ../SomeClass.java uses or overrides a deprecated API. We know what…
Marcel
  • 4,054
  • 5
  • 36
  • 50
25
votes
4 answers

Boolean expression order of evaluation in Java?

Suppose I have the following expression String myString = getStringFromSomeExternalSource(); if (myString != null && myString.trim().length() != 0) { ... } Eclipse warns me that myString might be null in the second phrase of the boolean expression.…
daveslab
  • 10,000
  • 21
  • 60
  • 86
25
votes
5 answers

Const correctness warnings c++

Does anyone know of any warnings that C++ compilers provide that help to enforce const correctness? For instance, it would be nice to have a warning produced by any C++ method that contains a non-const parameter that is never modified inside of the…
user809409
  • 491
  • 7
  • 10
24
votes
1 answer

What is the difference between the dead_code and unused lints?

What is the difference between #[allow(dead_code)] // ...some code and #[allow(unused)] // ...some code
109149
  • 1,223
  • 1
  • 8
  • 24
24
votes
4 answers

How to enable compiler warning when comparing char and unsigned char?

take for example the following C code : int main(int argc, char *argv[]) { signed char i; unsigned char count = 0xFF; for (i=0; i
sagi
  • 523
  • 3
  • 15
24
votes
3 answers

Ignore/only show errors/warnings from certain directory using CMake

main question: Is there a configuration for cmake, to show or ignore compiler warnings/errors only from a certain directory? alternative solution: How can I toggle this in QtCreator? background / motivation: I'm working on a bigger CMake-project and…
hardmooth
  • 1,202
  • 2
  • 19
  • 36
24
votes
3 answers

Turn off warnings coming from subprojects

Can someone help me to turn off warnings in Xcode 4 that I'm getting from subprojects? I have three subprojects, with a lot of warnings. The subprojects are provide by my customer's R&D studio. I would like to turn off the warnings there, to put…
Luca Bartoletti
  • 2,435
  • 1
  • 24
  • 46
23
votes
2 answers

Why is returning address of local variable or temporary only a warning and not an error?

Having just received a warning from the compiler for this function: template Matrix3x3 & operator - (Matrix3x3 const & p) { auto m = Matrix3x3(p); m.m11 = -m.m11; m.m12 = -m.m12; m.m13 = -m.m13; m.m21 = -m.m21; m.m22 =…
Robinson
  • 9,666
  • 16
  • 71
  • 115
23
votes
5 answers

Compiler warning CS1591: How to show that warning only for undocumented methods?

The C# compiler shows a warning (CS1591), if a public member is undocumented: Warning ... Missing XML comment for publicly visible type or member ... That includes all properties, methods, classes, enum value, etc. Question: Is there a way to…
Christian St.
  • 1,751
  • 2
  • 22
  • 41
23
votes
2 answers

Conditional references in .NET project, possible to get rid of warning?

I have two references to a SQLite assembly, one for 32-bit and one for 64-bit, which looks like this (this is a test project to try to get rid of the warning, don't get hung up on the paths):
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
22
votes
3 answers

C# Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first

I know these warnings are probably pointless.. But anyway I could get rid of them? I got 7 of these warnings. Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first This has something to do with the OR…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
22
votes
8 answers

Is it problematic to assign a new value to a method parameter?

Eclipse has an option to warn on assignment to a method's parameter (inside the method), as in: public void doFoo(int a){ if (a<0){ a=0; // this will generate a warning } // do stuff } Normally I try to activate (and heed) almost all…
sleske
  • 81,358
  • 34
  • 189
  • 227
22
votes
5 answers

srand (time (null)) causes compiler warning: implicit conversion loses integer precision

Apologies if this question has already been answered. #include #include #include using namespace std; int main () { srand( time(NULL) ); cout << rand(); } "implicit conversion loses integer precision: 'time_t' (aka…
user2576878
  • 223
  • 1
  • 2
  • 5
21
votes
8 answers

"redundant cast to java.lang.Object" warning for necessary cast

Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : …
Tom Hawtin - tackline
  • 145,806
  • 30
  • 211
  • 305