I have three functions below, I'm not sure why the second and the third one have a warning at *arr but the first one doesn't. What does the warning mean and how to fix this?
IDE: Clion 2017.3 MinGW64 5.0, CMake 3.9.4
Thank you.
int getFirstEven(int n, int *arr) {
for (int i = 0; i < n; ++i) {
if (arr[i] % 2 == 0)
return arr[i];
}
return -1;
}
int getLastOdd(int n, int *arr) {
int lastOdd = -1;
for (int i = 0; i < n; ++i) {
if (arr[i] % 2 != 0)
lastOdd = arr[i];
}
return lastOdd;
}
int countElement(int n, int *arr, int e) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (arr[i] == e)
cnt++;
}
return cnt;
}

clang++. Which compiler do you use?getFirstEvenmay reach the end of a non-void function without a return.