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
2 answers

Convert one character in a C array to uppercase gives C4244 warning

Here is my code where I want to convert just ONE character in the string to uppercase. TCHAR sPassword[16] = L"password"; INT iChar = toupper(sPassword[4]); sPassword[4] = iChar; It runs correctly, but I get a warning: warning C4244: '=':…
JeffR
  • 765
  • 2
  • 8
  • 23
1
vote
3 answers

Higher-order, partial function — where to place @unchecked annotation?

I've a piece of code for which I get a "match may not be exhaustive" warning from Scala 2.13.4, and I'd like to suppress that warning with the @unchecked annotation. Unfortunately, all my attempts of inserting @unchecked merely resulted in syntax…
1
vote
1 answer

My code runs in VSCode but does not run in DevC

#include #include void arraydescending(int array[]){ for (int j=0; j<9; j++){ for (int i=0; i<8; i++) { if(array[i]
1
vote
1 answer

Compiler warning: Conversion of integer to pointer at assignment

I'm doing the following: static uint32 myReadValue; static uint32 myNewValue; DoRead(10, &myReadValue); myNewValue = (uint32)(&myReadValue) | (3 << 8); whereby void DoRead(SomeEnumType, void * Ptr) { // some functionality } The compiler…
JohnDoe
  • 825
  • 1
  • 13
  • 31
1
vote
1 answer

Note: Anpr.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details warning in JComboBox

The warning show up after i use JComboBox i tried to hide it with @SuppressWarnings("deprecation") but it didn't worked after i recompiled it with -Xlint:unchecked it showed Anpr.java:61: warning: [unchecked] unchecked call to JComboBox(E[]) as a…
user14389228
  • 73
  • 1
  • 8
1
vote
1 answer

get g++ to warn on promotions

Is there a compiler flag that makes g++ warn on promotion? I am aware of g++ compiler flags for warning on conversion (such as -Wconversion, -Wsign-conversion), which makes sense as conversions are potentially quite dangerous, but I do not know of a…
Zorglub29
  • 6,979
  • 6
  • 20
  • 37
1
vote
1 answer

Getting problem with timing in C in visual studio 2010

I have a function for getting system time. The function is defined as follows. int getSystemTime(struct timeval tv, void * tz);{ DWORD milliseconds; milliseconds = timeGetTime(); tv->tv_sec = milliseconds / 1000; tv->tv_usec =…
thetna
  • 6,903
  • 26
  • 79
  • 113
1
vote
3 answers

Warning: "No '-renderInContext' method found"

I have this code, and it is working exactly as desired: UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage* image =…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
1
vote
0 answers

Pointer type mismatch in conditional expression: different behavior between compilers

Sample code: int f1(char c){ return c; }; int f2(int i ){ return i; }; int main(void) { return (1 ? f1 : f2)(0); } Different behavior between compilers: gcc (latest): gcc prog.c -Wall -Wextra -std=c89 -pedantic prog.c: In function…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

clang: warning: argument unused during compilation: '-rdynamic'

I tried to use -rdynamic option in my CMakeLists.txt file, like this: cmake_minimum_required(VERSION 3.5) project(Tmuduo CXX) ... set(CMAKE_CXX_STANDARD 11) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads…
Phoenix Chao
  • 390
  • 3
  • 19
1
vote
1 answer

return value ignored: 'scanf' (closed)

I'm writing a program with C and this is one of my functions: void group3() { char select[5]; printf("\nDetails etc."); printf("\nPlease confirm Yes/No if you would like to subscribe:"); scanf("%s", select); if (select == "Yes") …
cloud
  • 105
  • 9
1
vote
1 answer

W1035 Return value of function 'Test' might be undefined unexpectedly appears after adding a try-finally block

I have an unexpected W1035 on compiling: [dcc32 Warning] Unit1.pas(40): W1035 Return value of function 'Test' might be undefined function CheckFn() : Boolean; begin Result := True; end; function Test() : Boolean; begin try if(not…
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
1
vote
0 answers

Persistent "error C2220: the following warning is treated as an error"

I've recently moved a large codebase from VS2013 to VS2019 that builds for windows 32 and 64 bit targets. Debug and release versions compile with numerous warnings, although these are largely the same as existed in the VS2013 build. Most of them are…
Nimo
  • 324
  • 2
  • 15
1
vote
2 answers

Bit Shifting: Shift Count >= Width Of Type

The code below, when compiled, throws a warning caused by line 9: warning: shift count >= width of type [-Wshift-count-overflow] However, line 8 does not throw a similar warning, even though k == 32 (I believe). I'm curious why this behavior is…
Daniel
  • 2,345
  • 4
  • 19
  • 36
1
vote
1 answer

IDE0059 Unnecessary assignment of a value to 'result'

protected async Task HandleValidSubmit() { Mapper.Map(EditEmployeeModel, Employee); Employee result = null; if (Employee.EmployeeId != 0) { result = await EmployeeService.UpdateEmployee(Employee); } else …
HarryM
  • 21
  • 3