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
21
votes
5 answers

Is there an equivalent of gcc's -Wshadow in visual C++

-Wshadow will "Warn whenever a local variable shadows another local variable.". Is there an equivalent in Visual C++ (2008)? I tried /W4 but it didn't pick up on it. I also tried Cppcheck but that didn't see it either. e.g. if I inadvertently…
danio
  • 8,548
  • 6
  • 47
  • 55
21
votes
1 answer

How to allow dead_code and unused_imports for dev builds only?

The unused imports and dead code warnings are the most common that I've found while learning Rust, and they get annoying after awhile (a very short while, like a few seconds). Especially when they are mixed with compiler errors, because it makes the…
Reactgular
  • 52,335
  • 19
  • 158
  • 208
21
votes
3 answers

gcc warning: function used but not defined

I am getting the warning: function used but not defined. I have static __inline__ in header file say a.h. The header file is included in a.c. I would like put all those inline function which are in header files into the .c files. Following code…
thetna
  • 6,903
  • 26
  • 79
  • 113
21
votes
1 answer

clang++ (version 5) and LNK4217 warning

I am just learning how to code. I have installed clang version 5 on a windows 10 system using visual studio 14. I created a hello world cpp file to test that is working. Sample code #include using namespace std; int main() { cout <<…
Robin
  • 311
  • 2
  • 5
21
votes
2 answers

Will a "variableName;" C++ statement be a no-op at all times?

In C++ sometimes a variable will be defined, but not used. Here's an example - a function for use with COM_INTERFACE_ENTRY_FUNC_BLIND ATL macro: HRESULT WINAPI blindQuery( void* /*currentObject*/, REFIID iid, void** ppv, DWORD_PTR /*param*/ ) { …
sharptooth
  • 167,383
  • 100
  • 513
  • 979
21
votes
0 answers

Suppress warning without code

I am trying to suppress some warnings in Visual Studio, but the problem is that they don't have a code or anything I could use to identify them(or I can't find it). Most of these errors look like "The referenced component could not be loaded" or…
relysis
  • 1,065
  • 1
  • 14
  • 27
21
votes
3 answers

How to avoid deprecation warnings when @SuppressWarnings("deprecation") doesn't work?

We have a Java project. We enable -Xlint (enable warnings) and -Werror (treat warning as error) flags for javac, to make sure our code is warning-free. Recently we decide to deprecate a class. The problem is in some cases…
Reci
  • 4,099
  • 3
  • 37
  • 42
21
votes
7 answers

How to disable a specific nvcc compiler warnings

I want to disable a specific compiler warning with nvcc, specifically warning: NULL reference is not allowed The code I am working on uses NULL references are part of SFINAE, so they can't be avoided. An ideal solution would be a #pragma in just…
bcumming
  • 1,075
  • 2
  • 8
  • 17
21
votes
3 answers

IntelliJ says "Warning: java: foo/bar/Baz.java uses unchecked or unsafe operations", but it doesn't say in which line it is referring to

I am getting this warning: When I click on the image, it just opens the associated Editor, but it doesn't say the line number where the warning is raised. I don't want to add @SuppressWarning("unchecked") on the whole class... Any workaround/fix?
20
votes
5 answers

Why compiler is not giving error when signed value is assigned to unsigned integer? - C++

I know unsigned int can't hold negative values. But the following code compiles without any errors/warnings. unsigned int a = -10; When I print the variable a, I get a wrong value printed. If unsigned variables can't hold signed values, why do…
Navaneeth K N
  • 15,295
  • 38
  • 126
  • 184
20
votes
2 answers

After Updating Android Studio 3.1, I am getting these warnings after each build

Android Issues Warnings Stripped invalid locals information from 1 method. Stripped invalid locals information from 1 method. Message{kind=WARNING, text=Stripped invalid locals information from 1 method., sources=[Unknown source file], tool…
20
votes
2 answers

How to get the @SuppressWarnings warning name for an IntelliJ warning?

IntelliJ wrongly tells me that a field initializer is redundant, but it is in fact used by Lombok's @Builder.Default. I would like to suppress this warning using @SuppressWarnings but I don't know what the warning is called (alt-enter also gives me…
user1779715
20
votes
1 answer

Why am I getting an unused lambda capture warning?

I am passing a lambda with an init-captured loop counter like this: #include auto sq(int c, int x) { return c * x * x; } struct S { template void for_each(Fun fun) const { for (auto i = 1; i < 4; ++i) { …
TemplateRex
  • 69,038
  • 19
  • 164
  • 304
20
votes
4 answers

How to avoid warning about no return expression when using static_assert?

I have two libraries that I work with and I wrote a converter between some of the types/structs they use, for convenience. template struct unsupportedType : std::false_type {}; template FormatB getFormat() { …
NOhs
  • 2,780
  • 3
  • 25
  • 59
20
votes
2 answers

The difference between -pedantic-errors and -Werror=pedantic in gcc

What is the difference between using -pedantic-errors and -Werror=pedantic in gcc? According to the documentation of GCC there is a difference: -pedantic-errors Give an error whenever the base standard (see -Wpedantic) requires a diagnostic, in…
Supremum
  • 542
  • 7
  • 23