L
L
LuigiVampa922016-05-03 02:25:21
Android
LuigiVampa92, 2016-05-03 02:25:21

Why does the IDE find unreachable code in a loop?

Hello, I ran into an unexpected problem in C.
There is a function:
9d86318c7f0046229ffdacf2cad3a997.jpg
This is a piece of code from a utility written for Windows (however, nothing OS-specific is used there). I decided to use it in an android application. It would seem that there should be no problems in it, but the IDE says that there are already 5 of them:
1) b += 16 - unreachable code // As if the loop never runs
2) in = b - expecting : // Expecting a colon ?? ?
3) in < (b + 16) - expression result is unused
4) ++in - unreachable code // again as if the loop is never executed
5) /* closing bracket */ - syntax error, expecting ; // didn't understand at all
Under Windows everything works. Errors arose not because the bodies of the cycles are empty, if meaningful code is added to them, then it will be marked as unreachable. The code compiles, but if you call it, the application crashes.
Actually questions:
1) Why did it happen?
2) How to fix it?
3) I did not find a way to set up a debugger for C / C ++ code in android. I would be very grateful if you tell me how to do this. (I am using android studio and gradle-experimantal-plugin to build)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-05-03
@alsopub

Maybe I'll assume stupidity ...
At the end of the function is "return 0;", inside the function nothing "external" is modified.
Therefore, you can painlessly throw everything away, leaving only "return 0;", because no matter what is meaningful inside - the result of the function is zero.
Try to return not zero, but the result of calculations or modify the data by the data pointer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question