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
34
votes
7 answers

How to set '-Xuse-experimental=kotlin.experimental' in IntelliJ

while trying to build a Kotlin/Ktor application in IntelliJ, multiple warnings of the form Warning:(276, 6) Kotlin: This class can only be used with the compiler argument '-Xuse-experimental=kotlin.Experimental' are output. The warnings refer…
34
votes
7 answers

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

I was trying to answer this question. As suggested by the accepted answer, the problem with that code is that not all control paths are returning a value. I tried this code on the VC9 compiler and it gave me a warning about the same. My question is…
Naveen
  • 74,600
  • 47
  • 176
  • 233
33
votes
6 answers

strange warning about ExtensionAttribute

I'm getting a strange warning: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files\Reference…
JoelFan
  • 37,465
  • 35
  • 132
  • 205
33
votes
1 answer

How can I disable Haskell warning in small block?

I want to disable warning only some block of code. I searched Google but only find file scope or global scope disable method. Using cabal file or pragma {-# OPTIONS_GHC #-} Can I disable warning for specific function?
juhyung park
  • 503
  • 4
  • 8
32
votes
5 answers

g++ How to get warning on ignoring function return value

lint produces some warning like: foo.c XXX Warning 534: Ignoring return value of function bar() From the lint manual 534 Ignoring return value of function 'Symbol' (compare with Location) A function that returns a value is called just for…
Arun
  • 19,750
  • 10
  • 51
  • 60
31
votes
3 answers

Disabling a specific compiler warning in VS Code

I want to know how to suppress a specific compiler warning within VS Code for the entire project. I have seen this queston: Is it possible to disable specific compiler warnings? but it is for Visual studio, not Visual Studio Code. Here are the…
31
votes
7 answers

Initialise string function result?

I've just been debugging a problem with a function that returns a string that has got me worried. I've always assumed that the implicit Result variable for functions that return a string would be empty at the start of the function call, but the…
avenmore
  • 2,809
  • 3
  • 33
  • 34
31
votes
4 answers

Bad path warning, where is it coming from?

When I compile my project with compiler warnings (JDK 1.5) I get a bunch of bad path element warnings: Warning:: [path] bad path element "C:\Users\User\MyJava\common\lib\junit.jar": no such file or directory Warning:: [path] bad path element…
Yishai
  • 90,445
  • 31
  • 189
  • 263
30
votes
2 answers

build rules for xcode / iPhone

Im incorporating the facebook SDK into an update and i get compiler warnings for four files,in one of my targets each file gets two warnings like these. [WARN]warning: no rule to process file '$(PROJECT_DIR)/APP_NAME/Facebook.h' of type…
Jef
  • 4,728
  • 2
  • 25
  • 33
30
votes
5 answers

The parameter 'foo' should not be assigned -- what's the harm?

Compare this method: void doStuff(String val) { if (val == null) { val = DEFAULT_VALUE; } // lots of complex processing on val } ... to this method: void doStuff(String origVal) { String val = origVal; if (val == null)…
Matt McHenry
  • 20,009
  • 8
  • 65
  • 64
29
votes
1 answer

Any way to generate warnings for function-pointer comparisons?

It took me forever to track down that there was a bug in my code being triggered by /OPT:ICF: Because /OPT:ICF can cause the same address to be assigned to different functions or read-only data members (const variables compiled by using /Gy), it…
user541686
  • 205,094
  • 128
  • 528
  • 886
29
votes
1 answer

c++ warning: enumeration value not handled in switch [-Wswitch]

I am trying to compile following code without warnings: while (window.pollEvent(event)) { switch (event.type) { case sf::Event::Closed: window.close(); break; case sf::Event::KeyPressed: …
bluszcz
  • 4,054
  • 4
  • 33
  • 52
29
votes
5 answers

MSB3270: Mismatch between the processor architecture - Fakes Framework

Since I use Fakes Framework in my UnitTest, I get the following MSBuild warning. warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference…
Snowcrack
  • 549
  • 1
  • 5
  • 13
28
votes
5 answers

How to suppress Java compiler warnings for specific functions

We are always taught to make sure we use a break in switch statements to avoid fall-through. The Java compiler warns about these situations to help us not make trivial (but drastic) errors. I have, however, used case fall-through as a feature (we…
28
votes
4 answers

Globally suppress c# compiler warnings

In my app I have a fair number of entities which have fields which are getting their values set via reflection. (In this case NHibernate is setting them). I'd like to get rid of the "x is never assigned to and will always have its default value 0"…
pondermatic
  • 6,453
  • 10
  • 48
  • 63