Questions tagged [warnings]

A warning is often issued on recognizing a potential high-risk situation, a probable misunderstanding, degraded service or imminent failure.

A warning-level error message shown by a compiler indicates a piece of code which the compiler recognizes as being potentially a problem, but which is syntactically correct such that the compiler is able to continue.

The seriousness of warning may vary from basically an error to something that could be considered just as bad programming style. Most of compilers provide keys to disable default warnings and may provide keys to enable warnings that are disabled by default (e.g. -Wall, -Wextra, -Werror).

5829 questions
85
votes
7 answers

Is using #pragma warning push/pop the right way to temporarily alter warning level?

Once in a while it's difficult to write C++ code that wouldn't emit warnings at all. Having warnings enabled is however a good idea. So it is often necessary to disable warnings around some specific construct and have them enables in all other…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
85
votes
7 answers

How to test with Python's unittest that a warning has been thrown?

I have a following function in Python and I want to test with unittest that if the function gets 0 as argument, it throws a warning. I already tried assertRaises, but since I don't raise the warning, that doesn't work. def isZero(i): if i !=…
Tomas Novotny
  • 7,547
  • 9
  • 26
  • 23
83
votes
6 answers

Auto fix TSLint Warnings

[64, 1]: space indentation expected [15, 27]: Missing semicolon [109, 36]: missing whitespace [111, 24]: missing whitespace [70, 1]: Consecutive blank lines are forbidden I keep getting warnings like these from TSLint. There…
ANKIT HALDAR
  • 1,365
  • 1
  • 10
  • 17
81
votes
4 answers

Selectively remove a warning message using GCC

This piece of code: Int32 status; printf("status: %x", status) gives me the following warning: jpegthread.c:157: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'Int32' I know I can get rid of it by casting the type, but…
shodanex
  • 14,975
  • 11
  • 57
  • 91
81
votes
1 answer

What is the meaning of the type safety warning in certain Java generics casts?

What is the meaning of the Java warning? Type safety: The cast from Object to List is actually checking against the erased type List I get this warning when I try to cast an Object to a type with generic information, such as in the…
Mike Stone
  • 44,224
  • 30
  • 113
  • 140
79
votes
18 answers

React: validateDOMNesting: #text cannot appear as a child of

Can you explain me why react show warning Warning: validateDOMNesting(...): #text cannot appear as a child of . See Router > RouterContext > CarWashPage > AllCarWashTable > tr > #text.? I don't see any text inside tag tr Code that renders…
Bizon4ik
  • 2,604
  • 4
  • 20
  • 46
77
votes
11 answers

Suppress Ruby warnings when running specs

I'm looking for a way to suppress Ruby warnings when I run my specs. spec spec/models/account_spec.rb I receive warnings such as: DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, ... warning: already initialized constant…
Jey Balachandran
  • 3,585
  • 5
  • 27
  • 36
77
votes
6 answers

Exclude all permission denied messages from "du"

I am trying to evaluate the disk usage of a number of Unix user accounts. Simply, I am using the following command: du -cBM --max-depth=1 | sort -n But I’ve seen many error message like below. How can I exclude all such “Permission denied” messages…
Wen_CSE
  • 1,225
  • 2
  • 10
  • 8
76
votes
17 answers

Avoiding unused variables warnings when using assert() in a Release build

Sometimes a local variable is used for the sole purpose of checking it in an assert(), like so - int Result = Func(); assert( Result == 1 ); When compiling code in a Release build, assert()s are usually disabled, so this code may produce a warning…
Hexagon
  • 6,845
  • 2
  • 24
  • 16
75
votes
9 answers

How can I hide "defined but not used" warnings in GCC?

I have a bunch of compile time asserts, such as: CASSERT(isTrue) or CASSERT2(isTrue, prefix_) When compiling with GCC I get many warnings like 'prefix_LineNumber' defined but not used. Is there a way I can hide warnings for compile time asserts? I…
user34537
75
votes
2 answers

Eliminating warnings from scikit-learn

I would like to ignore warnings from all packages when I am teaching, but scikit-learn seems to work around the use of the warnings package to control this. For example: with warnings.catch_warnings(): warnings.simplefilter("ignore") from…
Chris Fonnesbeck
  • 4,143
  • 4
  • 29
  • 30
75
votes
8 answers

PHP - warning - Undefined property: stdClass - fix?

I get this warning in my error logs and wanted to know how to correct this issues in my code. Warning: PHP Notice: Undefined property: stdClass::$records in script.php on line 440 Some Code: // Parse object to get account id's // The response…
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
72
votes
3 answers

Xcode 4 warning "Expression result unused” for NSURLConnection

I'm just trying to do my usual data transfert. I define my NSMutableURLRequest then call [[NSURLConnection alloc] initWithRequest:request delegate:self]; This used to be ok with Xcode 3 but Xcode 4 warns me about "Expression result unused" on that…
Johann
  • 12,158
  • 11
  • 62
  • 89
71
votes
6 answers

GCC 7, -Wimplicit-fallthrough warnings, and portable way to clear them?

We are catching warnings from GCC 7 for implicit fall through in a switch statement. Previously, we cleared them under Clang (that's the reason for the comment seen below): g++ -DNDEBUG -g2 -O3 -std=c++17 -Wall -Wextra -fPIC -c authenc.cpp asn.cpp:…
jww
  • 97,681
  • 90
  • 411
  • 885
70
votes
5 answers

R: how to clear all warnings

I would like to clear the warnings() list using a command line. I have tried with no success > rm(last.warning, envir = baseenv()) Error in rm(last.warning, envir = baseenv()) : cannot remove variables from the base environment any idea?
RockScience
  • 17,932
  • 26
  • 89
  • 125