Questions tagged [warnings]

16 questions
29
votes
9 answers

Why should one want to disable compiler warnings?

This answer and the comments added to it show a way to disable several compiler warnings using #pragma directives. Why would one want to do that? Usually the warnings are there for a reason, and I've always felt that they're good reasons. Is there…
takrl
  • 439
  • 1
  • 8
  • 19
21
votes
3 answers

Is it good practice to avoid warnings and notices?

I've generally been working with PHP warnings and notices off, since I work on a lot of projects where it's already in live production. Now, if I turn on the warnings and notices on these live production websites, they'll be overloaded with…
Audite Marlow
  • 379
  • 2
  • 7
17
votes
7 answers

Why unused variables is such an issue?

I was cleaning unused variables warnings one day, and I started to ponder, what exactly is the problem about them? In fact, some of them even help in debugging (e.g. inspect exception details, or check the return-value before returned). I couldn't…
13
votes
3 answers

Is it a good practice to use suppress warnings in your code?

I use @SuppressWarnings("unchecked") and @SuppressWarnings("null") mostly above methods to let the code compile without any warnings but I have my doubts. Found this Stackoverflow question. Jon Skeet wrote an answer to it which I find…
Bilesh Ganguly
  • 343
  • 1
  • 3
  • 13
9
votes
5 answers

How to deal with warnings in a legacy project

I work on a C++ project that generates bajillions of warnings. Most of the warnings appeared after the code was written: Initially the project used Visual C++ 8, soon switching to 9, but there is little difference in the generated warnings.…
Jan Hudec
  • 18,250
  • 1
  • 39
  • 62
5
votes
4 answers

Is a compiler warning for 64bit to 32bit `size_t` truncation actually useful?

I have been looking at VC++'s C4267: Compiler Warning (level 3) C4267 'var' : conversion from 'size_t' to 'type', possible loss of data The compiler detected a conversion from size_t to a smaller type. To fix this warning, use size_t instead of…
Martin Ba
  • 7,578
  • 7
  • 34
  • 56
4
votes
2 answers

Handling compiler bugs in Continuous Integration

I believe that warnings should be treated as errors. If you start ignoring warnings you'll start missing "important" warnings among the "unimportant" ones. So my Continuous Integration system fails a build if there are warnings. One of my compilers…
sourcenouveau
  • 6,460
  • 4
  • 29
  • 44
3
votes
6 answers

Waiting until end of project to remove commented out code, remove unused code, and resolve compiler warnings

A co-worker of mine is working on project solo but would still like to have other team members review their code upon reaching certain milestones. Unfortunately, they also want to wait until the end of the project to remove commented out code,…
3
votes
1 answer

Are there any standards for labelling stdout/stderr messages?

I'm making a console application, and over time I have been developing my own tools and practices for outputting text; a process that keeps evolving. For example, these days I have 4 main types of messages formatted roughly like the following: bold(…
Anon
  • 3,565
  • 3
  • 27
  • 45
3
votes
2 answers

Is it a good practice to choose the highest warning level in C++ programming?

I used to select the default warning level in C++ programming. For example, in VS, the default warning level is Level3 (/W3) and No (/WX-) (don't treat warnings as errors). I am wondering is it a good practice to choose highest warning level in C++…
herohuyongtao
  • 141
  • 1
  • 6
2
votes
1 answer

Capturing warnings when batch processing is ignored

My client has a process which iterates over a number of actions that may or may not apply to a users portfolio. Quite frequently, processing of an action may give up and jump to the next action or portfolio without the process stopping (i.e.…
Component 10
  • 223
  • 1
  • 5
1
vote
2 answers

Example of problem caused by casting Object[] to E[]

I've heard here and there that arrays contain runtime data about their type, making you unable to instantiate an E[] (E being a generic type parameter, for example in a class Foo), and that while you can achieve the same effect by doing (E[]) new…
Phoenix
  • 758
  • 7
  • 14
1
vote
2 answers

Why am I getting field visibility warnings in Sonar?

Some static analysis tools flag non-private fields with Variable '[nameHere]' must be private and have accessor methods. Sonar consistently presents such warnings and wants to change all protected variables in my code to private, why is this? I'm…
Reginald
  • 113
  • 1
  • 4
1
vote
2 answers

How much warnings in C to enable?

This is a tiny project of about 2000LOC. It is being compiled with -Wall. Now, I tried adding -Wextra. Two things happened: Some minor but valid warnings popped up, e.g. Comparing signed with unsigned Some minor but false warnings popped up, e.g.…
Vorac
  • 7,073
  • 7
  • 38
  • 58
-1
votes
1 answer

When to use using #pragma warning disable

Is there a general rule about disabling warnings in your code? In my particular case, an unreachable code warning was issued because of an if statement testing a constant value, where it could be replaced with a compilation directive. I believe that…
Roberto
  • 193
  • 6
1
2