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
28
votes
3 answers

How can I get gcc to warn me about "int i = i;"

A simple program: int main() { long i = i; return 0; } Compiling as C gives no errors and no warnings. $ gcc -Wall -Wextra -pedantic 1.c Compiling as C++ gives a warning: $ c++ -Wall -Wextra -pedantic 1.c 1.c: In function ‘int…
28
votes
5 answers

What is the underlying difference between printf(s) and printf("%s", s)?

The question is plain and simple, s is a string, I suddenly got the idea to try to use printf(s) to see if it would work and I got a warning in one case and none in the other. char* s = "abcdefghij\n"; printf(s); // Warning raised with gcc…
Mikael
  • 969
  • 12
  • 24
28
votes
2 answers

Why is GCC tricked into allowing undefined behavior simply by putting it in a loop?

The following is nonsensical yet compiles cleanly with g++ -Wall -Wextra -Werror -Winit-self (I tested GCC 4.7.2 and 4.9.0): #include #include int main() { for (int ii = 0; ii < 1; ++ii) { const std::string& str = str;…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
28
votes
2 answers

What warnings are included in Clang's -Wall and -Wextra?

I've found Clang's documentation to be quite poor. I haven't been able to find much of a list of available Clang warning flags. I'm interested particularly in C/C++ warnings, but this is a bit of a general issue. GCC lists and describes warnings…
Jetski S-type
  • 1,138
  • 2
  • 16
  • 32
28
votes
5 answers

bootstrap class path not set

So I am getting- warning: [options] bootstrap class path not set in conjunction with -source 1.6 And I am about to ask 3 questions about it. I understand that I need to set the bootstrap class path but I am not sure I understand how. A quick google…
Stephopolis
  • 1,765
  • 9
  • 36
  • 65
28
votes
4 answers

warning: return type defaults to ‘int’ [-Wreturn-type]

I'm a Linux user who started learning C and I'm trying to compile this source that I typed: #include main() { float c,d; c = 10215.3; d = c / 3; printf("%3.2f\n",d); return 0; } It compiled with…
JoshD
  • 283
  • 1
  • 3
  • 4
27
votes
7 answers

How to overcome pointless C++ compiler warnings elegantly?

This question is not bound to any specific compiler warning, the following is just an example. Currently when I want a loop that checks an exit condition inside: while( true ) { doSomething(); if( condition() ) { break; } …
sharptooth
  • 167,383
  • 100
  • 513
  • 979
27
votes
3 answers

How to disable Xcode warning "Enable Base Internationalization"?

This warning started to appear on Xcode 10 Beta 6. I perfectly understand its meaning, yet I wish to disable it. Any way to do that?
Joshua
  • 1,974
  • 2
  • 23
  • 39
27
votes
2 answers

Why didn't the compiler warn me about an empty if-statement?

I'm using Keil µVision v4.74 and have enabled the option "All Warnings". I wrote the following intentional code: if(condition matched) { // Do something } When I rebuilt my project, I got 0 errors, 0 warnings. However, when I accidentally…
AlphaGoku
  • 968
  • 1
  • 9
  • 24
26
votes
3 answers

"Consider app.config remapping of assembly ..." warning in F#

After I installed VS11, I started to get the following error: Consider app.config remapping of assembly "FSharp.Core, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "2.0.0.0" [C:\Program Files (x86)\Reference…
Oldrich Svec
  • 4,191
  • 2
  • 28
  • 54
26
votes
2 answers

Can you add custom compiler warnings in Objective-C?

(I found the answer to this elsewhere while writing the question, but I thought it might be helpful to others if I posted it since I couldn't find anything here.) I want to mark methods that need better error handling. I'd like them to show up as…
zekel
  • 9,227
  • 10
  • 65
  • 96
26
votes
4 answers

Gradle: List deprecated features

I am getting a warning about the usage of deprecated features in my build. Is there a way to list all the deprecated features so that I may go through and update my code? *clarification I know I can go to the Gradle documentation and see what is now…
Ed Dunn
  • 1,152
  • 3
  • 11
  • 27
25
votes
4 answers

How to fix "Protocol Not Implemented"

When I make a new controller called TestController, I insert to the interface of Test.h When I run the app on the simulator, there are many issues that say…
user4951
  • 32,206
  • 53
  • 172
  • 282
25
votes
6 answers

Impact on style of GHC -Wall

It is considered good practice to enable GHC warnings with -Wall. However, I've found out that fixing those warnings has a negative effect for some types of code constructs. Example 1: Using the do-notation equivalent of f >> will generate a…
gawi
  • 13,940
  • 7
  • 42
  • 78
25
votes
2 answers

Turn off Xcode's unused variable warnings while typing

I'm sick to death of Xcode's prolific use of live "unused variable" warnings while I am typing. I keep thinking I have an error in my syntax, stop what I'm doing, check the warning, only to see it's an unused variable warning. Of course it's…
devios1
  • 36,899
  • 45
  • 162
  • 260