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
41
votes
1 answer

unchecked call to ArrayAdapter

I get the following warning when I instantiate my ArrayAdapter (compiles fine): warning: [unchecked] unchecked call to ArrayAdapter(android.content.Context,int,java.util.List) as a member of the raw type android.widget.ArrayAdapter …
xil3
  • 16,305
  • 8
  • 63
  • 97
41
votes
4 answers

What is the "Ignoring InnerClasses attribute" warning output during compilation?

I am new to Android and am using the Ical4j library for parsing ICS (Outlook calendar) files. However, when I build my application in Eclipse, the following warning appears many times in the console: [2010-07-22 15:58:31 - Google Calendar Upload]…
RMK
  • 779
  • 3
  • 9
  • 13
40
votes
4 answers

Fix warning "C-style for Statement is deprecated" in Swift 3

I have update Xcode to 7.3 and now I have a warning to the function that I use to create random strings. I have tried to change the for statement with for (i in 0 ..< len){...} however, the warning became an error. How can I remove the…
SNos
  • 3,430
  • 5
  • 42
  • 92
39
votes
3 answers

#pragma warning disable & restore

I have used c# to create a First Project. I have many warning errors and all these warning errors are to be single Error(Internal compiler error. See the console log for more information.) For Reducing the warning errors I used #pragma Warning…
SaravanaKumar
  • 739
  • 1
  • 7
  • 17
39
votes
3 answers

Disable specific warnings in GCC

On Microsoft compilers, specific warnings can be disabled with a #pragma, without disabling other warnings. This is an extremely useful feature if the compiler warns over something that "has to be done". Does GCC at this point have a similar…
Matthias Wandel
  • 6,383
  • 10
  • 33
  • 31
38
votes
7 answers

Can GCC warn me about modifying the fields of a const struct in C99?

I stumbled upon a small issue while trying to make const-correct code. I would have liked to write a function that takes a pointer to a const struct, to tell to the compiler "please tell me if I am modifying the struct, because I really do not want…
Samuel Navarro Lou
  • 1,168
  • 6
  • 17
37
votes
6 answers

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

A common source of bugs in C or C++ is code like size_t n = // ... for (unsigned int i = 0; i < n; i++) // ... which can infinite-loop when the unsigned int overflows. For example, on Linux, unsigned int is 32-bit, while size_t is 64-bit, so if n…
nh2
  • 24,526
  • 11
  • 79
  • 128
37
votes
11 answers

How to avoid Visual Studio Code warning: "[myfile].java is a non-project file, only syntax errors are reported"

I am running a build task in a Java project in Visual Studio Code. The warning in the "PROBLEMS" tab: [myfile].java is a non-project file, only syntax errors are reported It refers to the first line where I load in the class file containing the…
37
votes
5 answers

Disable GCC "may be used uninitialized" on a particular variable

I'm getting this warning on a stack variable: warning: object.member may be used uninitialized in this function In this case I do not wish to force initialization to just to get rid of the warning as it consumes CPU cycles. The variable is a POD…
edA-qa mort-ora-y
  • 30,295
  • 39
  • 137
  • 267
37
votes
1 answer

GCC does not honor 'pragma GCC diagnostic' to silence warnings

We recently enabled -Wall for a project. Its enabled when GCC is at 4.7 or above (or Clang) because we can use GCC diagnostic to manage the output from the elevated warnings. We want to manage them from the source code, and not via command line…
jww
  • 97,681
  • 90
  • 411
  • 885
37
votes
3 answers

What does the "padding class 'Tester' with 4 bytes" warning mean?

For this simplified test case: #include class Tester { int foo; std::map smap; }; int main() { Tester test; return 0; } I get the following compiler warning: $ clang++ -std=c++98 -Weverything test.cc…
Dun Peal
  • 16,679
  • 11
  • 33
  • 46
37
votes
8 answers

Is there a way to get VS2008 to stop warning me about unreachable code?

I have a few config options in my application along the lines of const bool ExecuteThis=true; const bool ExecuteThat=false; and then code that uses it like if(ExecuteThis){ DoThis(); } if(ExecuteThat){ DoThat(); } //unreachable code warning…
Earlz
  • 62,085
  • 98
  • 303
  • 499
36
votes
11 answers

What does "control reaches end of non-void function" mean?

I've been getting strange compiler errors on this binary search algorithm. I get a warning that control reaches end of non-void function. What does this mean? int binary(int val, int sorted[], int low, int high) { int mid = (low+high)/2; …
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
36
votes
5 answers

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

In my Eclipse project are a handful of generated .java files that I need to use for SQLJ and I can't move to a separate project (due to Administrative Overhead). These files are also regularly regenerated so editing them is unfortunately…
kutuzof
  • 660
  • 1
  • 7
  • 22
34
votes
3 answers

Why does throwing 2 exceptions in a row not generate an unreachable code warning?

Why do the following lines of code not create a compiler warning? void Main() { throw new Exception(); throw new Exception(); } As I see it, the compiler should inform you that the second throw exception cannot be reached.
DaveShaw
  • 52,123
  • 16
  • 112
  • 141