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
1
vote
1 answer

How can compiler warnings be suppressed?

There are some compiler warnings that are caused either by the legacy code or metadata from Microsoft or cannot be resolved. These warnings make it harder to notice actual compiler warnings. How can compiler warnings be supressed so they do not…
FH-Inway
  • 4,432
  • 1
  • 20
  • 37
1
vote
1 answer

C++: disable implicit conversion warnings

I'm using MSVC, but it would be a plus to mention the right flags for the other major compilers. I need the flags just for experimental purposes. These are some examples of the warnings I'm referring to: warning C4244: '=': conversion from 'T' to…
uIM7AI9S
  • 353
  • 4
  • 13
1
vote
1 answer

Fortran program using character variable with allocatable length always shows a warning when compiling

I have the following code that uses a character variable with allocatable length. PROGRAM testprog IMPLICIT NONE CHARACTER(LEN=5) :: param CHARACTER(LEN=:), ALLOCATABLE :: val param = '12455' val = param WRITE(*,*) val END…
Emilio
  • 190
  • 1
  • 3
  • 10
1
vote
1 answer

Why calling SetConsoleCtrlHandler() triggers a warning?

#include BOOL MyCtrlHandler(DWORD ctrlType) { return TRUE; } int main(void) { SetConsoleCtrlHandler(MyCtrlHandler, TRUE); return 0; } The function signature matches the doc: The PHANDLER_ROUTINE type defines a pointer to…
rom1v
  • 2,752
  • 3
  • 21
  • 47
1
vote
2 answers

Incompatible pointer when int and long are the same?

When compiling C for a platform where int and long are both 32 bits, and long long is 64 bit (like clang or gcc -m32 or clang's wasm32-unknown-wasi target), I get errors about incompatible pointer types: int32_t *i1 = NULL; long *l1 = i1; int64_t…
corvus_192
  • 362
  • 4
  • 15
1
vote
1 answer

Export all Eclipse warnings to a file

Is there any way I can export all markers Eclipse has found when compiling? A legacy project of mine has quite a bit of warnings and I want to summarize them in a table so I can split them up by e.g. package, type and other factors. If I'm able to…
Bonnev
  • 947
  • 2
  • 9
  • 29
1
vote
3 answers

std::array: Why is there no warning or error on `at(-2)`?

The book says that std::array is safer and simpler than other methods of the assignment. Here's my code: #include #include using namespace std; int main() { array a = {1, 2, 3, 4, 5}; a.at(-2) = 100; cout <<…
1
vote
1 answer

Why does IntelliJ want me to construct an empty constructor?

intelliJ message I am new to Java and I understand constructors(I guess), but why does my code does not work until I construct an empty constructor? When I already have a constructor with parameters etc of that class.
1
vote
1 answer

GCC Werror flag leads to "no option" error

I found the Wabsolute-value warning which I want to use as an error. However I get cc1.exe:-1: error: error: -Werror=absolute-value: no option -Wabsolute-value When I try the warning itself, I get : :-1: error: error: unrecognized command line…
1
vote
0 answers

How can we avoid pragma pack warnings from windows headers when using /external compiler options?

Having found https://devblogs.microsoft.com/cppblog/broken-warnings-theory/ we tried it out in the hope of focussing our /Analyze builds on finding problems in our own code. We used c /analyze /analyze:stacksize131072 /analyze:WX-…
STB
  • 11
  • 1
1
vote
1 answer

casting unsigned to complex causes sign-conversion warning

Consider the following code: #include int main() { unsigned u = 1u; auto result = static_cast>(u); return 0; } Compiling with g++ -std=c++11 -Werror -Wsign-conversion -o a.out source_file.cpp Causes compile…
misev
  • 349
  • 3
  • 11
1
vote
1 answer

Make msvc C4706 go away without pragmas

Following code in MSVC generates warning about assignment in conditional expression. https://godbolt.org/z/i_rwY9 int main() { int a; if ((a = 5)) { return 1; } return a; } Note that I tried to use the double () around if…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
1
vote
2 answers

C++ "lossy coversion" warning for member function return value

The C++ compiler (gcc version 4.4.7 20120313 (Red Hat 4.4.7-23.0.1) (GCC)) doesn't issue expected warning when converting long long to int (see the code example below). // compiler: gcc version 4.4.7 20120313 (Red Hat 4.4.7-23.0.1) (GCC) // compiled…
1
vote
1 answer

Suppress "stack size cannot be dynamically determined" warnings?

I'm getting a CUDA warning saying ptxas warning : Stack size for entry function '_Z13a_test_kernelv' cannot be statically determined. Now, I know what it means, and there's a SO question about why it happens. What I want to suppress the warning…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
vote
3 answers

Silence WCast-function-type on a function structure

I have the following warning : cast between incompatible function types from ‘int (*)(pile *)’ {aka ‘int (*)(struct pile *)’} to ‘void (*)(void *)’ [-Wcast-function-type] I don't have any idea of how I can fix this warning. Structure typedef…
NoobZik
  • 87
  • 9
1 2 3
99
100